bat 删除上个月的文件

@echo off

rem now month-1
set date=%date:~0,4%-%date:~5,2%-%date:~8,2%
set a=%date:~0,4%
set b=%date:~5,2%
set /A b=%b%-1
if  %b% lss 10 set b=0%b%

for /l %%i in (1 1 31) do (
if %%i gtr 9  if exist E:\name_%a%-%b%-%%i.rar (del E:\name_%a%-%b%-%%i.rar)
if %%i lss 10 if exist E:\name_%a%-%b%-0%%i.rar (del E:\name_%a%-%b%-0%%i.rar)

echo E:\poscowh_%a%-%b%-%%i.rar
)

你可能感兴趣的:(bat)