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 echoed testing purposes. after you've verified command correct, change echo(del del delete files.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -