setlocal enabledelayedexpansion
for /f "tokens=1-3 delims=- " %%a in ('date /t') do set nowdate=%%a%%b%%c
for /f %%a in ('dir d:\adupdate /a:d /b /o:d^|findstr "^*$"') do (
set lodpatch=%%a
if %lodpatch:~0,8% neq %nowdate% (del d:\adupdate\%%a)
)
我想删除早于当天生成的文件夹。因为文件夹会有其他后缀,所以想截取前8位做比较。求在for循环中引用当前变量的方法。%lodpatch:~0,8% 为什么不起作用呢?
谢谢
[ Last edited by shrek on 2010-12-8 at 20:42 ]
for /f "tokens=1-3 delims=- " %%a in ('date /t') do set nowdate=%%a%%b%%c
for /f %%a in ('dir d:\adupdate /a:d /b /o:d^|findstr "^*$"') do (
set lodpatch=%%a
if %lodpatch:~0,8% neq %nowdate% (del d:\adupdate\%%a)
)
我想删除早于当天生成的文件夹。因为文件夹会有其他后缀,所以想截取前8位做比较。求在for循环中引用当前变量的方法。%lodpatch:~0,8% 为什么不起作用呢?
谢谢
[ Last edited by shrek on 2010-12-8 at 20:42 ]



