windows - Batch File delete newest file -
how delete newest file in folder using batch script?
all results have found show how delete oldest files or delete them after n days.
links : batch file delete files older n days , batch script delete oldest folder in given folder
thank you
for /f %%a in ('dir /b /o-d /a-d %the_directory%') echo("%the_directory%\%%a"&goto deldone :deldone
would approach. rudely escapes for
loop having deleted first filename encountered in sorted-in-reverse-date-order (/o-d
) list.
this saves having read entire list. not such problem few files, can pain thousands.
the required del command merely echo
ed testing purposes. after you've verified command correct, change echo(del
del
delete files.
Comments
Post a Comment