Answer the question
In order to leave comments, you need to log in
How to add script to bat file?
Help solve the problem.
There is a batch file:
pushd "C:\Test" && (forfiles /d -1 /m *.css /c "cmd /c del /f /q @file")
popd
Answer the question
In order to leave comments, you need to log in
It is clear that forfiles will not work for your purposes.
You can take advantage of the dir command's ability to sort files on output. You can see an example in the question that was here the other day:
You need to traverse by original files (not copies), then use the above dir to get the list "original file + its copies", sorted by date of modification in descending order, leave the first 3 files, delete the rest.
If you want details, then describe how and when you create copies of files and how names of copies are formed. Where are the copies and original files?
And in general I would like to understand what you are trying to do with this script. Apparently this is something like a system of cyclic backup of source texts with the preservation of the last few copies. Why not use git for this?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question