batch file remove all but the newest 10 files

后端 未结 2 1716
我在风中等你
我在风中等你 2021-01-20 17:55

I have the following in a batch file:

:REMOLDFILES
ECHO Removing files older than 14 days. >>%LOGFILE%
cd /d %BKUPDIR%
FOR /f \"skip=14 delims=\" %%A I         


        
2条回答
  •  时光取名叫无心
    2021-01-20 18:29

    You could use FOR /F SKIP to ignore the last 10 most recently modified entries after sorting by last modified date:

    for /f "skip=10 eol=: delims=" %%F in ('dir /b /o-d *.zip') do @del "%%F"
    

提交回复
热议问题