中国DOS联盟论坛

中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net  论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

游客:  注册 | 登录 | 命令行 | 会员 | 搜索 | 上传 | 帮助 »
作者:
标题: Findstr的问题 上一主题 | 下一主题
sylovanas
初级用户





积分 107
发帖 42
注册 2007-9-3
状态 离线
『楼 主』:  Findstr的问题

这里写了一个用Findstr搭配dir来找在从当月开始算起往前三个月之内,在一些固定资料夹中将exe com档案列出并显示修改日期以及档案大小

但到最后的Findstr 要找exe com的时候最后就没有列出任何东西
不知道最后面的Findstr能不能这样用?

代码如下:
@if not defined debug @echo off
@prompt $
set system=%systemroot%\system32

if exist C_File.dat del C_File.dat /Q
if not exist Time_B.reg regedit /e /a "Time_B.reg" "HKEY_CURRENT_USER\Control Panel\International"

@(
echo REGEDIT4
echo [HKEY_CURRENT_USER\Control Panel\International]
echo "iDate"="2"
echo "iMeasure"="0"
echo "iTime"="1"
echo "iTLZero"="1"
echo "sDate"="-"
echo "sLongDate"="yyyy-MM-dd"
echo "sShortDate"="yyyy-MM-dd"
echo "sTimeFormat"="HH:mm"
echo "iCountry"="1"
echo "iDigits"="2"
echo "iLZero"="1"
echo "sDecimal"="."
echo "sThousand"=","
echo "sTime"=":"
)> Time_A.reg

regedit /s "Time_A.reg"
del Time_A.reg /Q

set "year_t=%date:~0,4%"
set "month_t=%date:~5,2%"
echo %month_t% | Findstr "0." >nul && set month_t=%month_t:~1,1%

:: 1 month
set /a month_1=%month_t%-1
set /a year_1=%year_t%
if %month_1% EQU 0 (
        set /a year_1=%year_1%-1
        set /a month_1=12
        )

:: 2 month
set /a month_2=%month_1%-1
set /a year_2=%year_1%
if %month_2% EQU 0 (
        set /a year_2=%year_2%-1
        set /a month_2=12
        )

:: 3 month
set /a month_3=%month_2%-1
set /a year_3=%year_2%
if %month_3% EQU 0 (
        set /a year_3=%year_3%-1
        set /a month_3=12
        )

if %month_1% LSS 10 set month_1=0%month_1%
if %month_2% LSS 10 set month_2=0%month_2%
if %month_3% LSS 10 set month_3=0%month_3%

set "Today=^%year_t%-%month_t%"
set "1month=^%year_1%-%month_1%"
set "2month=^%year_2%-%month_2%"
set "3month=^%year_3%-%month_3%"

call :C_File %systemroot%
call :C_File %system%
if defined Temp call :C_File %temp%
goto end

:C_File
for /f "tokens=1,3,*" %%a in (
        'dir /tc /a-d "%~1\*" ^| Findstr "%today% %1month% %2month% %3month%"'
                ) do for /f "tokens=*" %%g in ('echo %~1\%%c') do echo %%a . %%~tg %%~zg %%~g >> C_File.dat
goto:eof

:end
Findstr -i "\.exe$ \.com$" C_File.dat

del C_File.dat /Q
regedit /s "Time_B.reg"
@prompt $P$G
最后面的Findstr如果改成
Findstr -i "\.exe \.com" C_File.dat 就可以正常显示
但这样只要中间字符有.exe和.com的也一样会显示出来

请问有没有什么方式可以修正的?

[ Last edited by sylovanas on 2008-9-4 at 06:01 PM ]

2008-9-4 16:34
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复
huahua0919
银牌会员




积分 1608
发帖 780
注册 2007-10-7
状态 离线
『第 2 楼』:  

findstr/ic:""

2008-9-4 18:35
查看资料  发送邮件  访问主页  发短消息 网志   编辑帖子  回复  引用回复

请注意:您目前尚未注册或登录,请您注册登录以使用论坛的各项功能,例如发表和回复帖子等。


可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题



论坛跳转: