|This is from an old post of a batch file provided by M2.|
deleting old backups
pushd "C:\Program Files\Microsoft SQL Server\MSSQL$SIMS\BACKUP"
dir /b/od *.zip > %TEMP%\templist
set /p file2del=<%TEMP%\templist
call :deleter %file2del%
dir /a-d *.zip |find "File(s)">%TEMP%\#
for /f "tokens=1" %%T in (%TEMP%\#) do if %%T LEQ 14 goto :eof
The script executes perfectly and deletes all but the last 14 *.zip files.
But I tested the script when there are no (zero) (none) *.zip in the specified directory, then the script just loops endlessly.
For some reason this script does not consider 0 LEQ 14 and does not goto :eof
Does this make sense? M2 are you still out there? Anyone? Ideas?