Answer the question
In order to leave comments, you need to log in
How to delete files when a certain number of them (with verification) is exceeded by a script?
Good afternoon. It is necessary to leave the last 7 files in the folder by the date of creation, and delete the rest, but before that, check that the folder really has at least 7 files. How to remove it seems clear, how to calculate, too, seems to understand, but I can’t put it all together. Thank you!
Answer the question
In order to leave comments, you need to log in
pushd d:\test
for /f "skip=7 delims=" %%I in ('dir /b /a-d /o-d /tc') do del "%%I"
popd
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question