Deleting the oldest file in a folder with batch scripting
Solution 1
That dredged up some painful memories! I found this one:
http://www.chebucto.ns.ca/~ak621/DOS/Bat-Adv3.html#OLD
I won't cut and paste the script as there is a really nice write up there.
Solution 2
I think this should be possible with the forfiles
command. Technet link.
But it is not included in WinXP. There are however "Resource Kits" from Microsoft which include several Tools, forfiles is one of them. Try to google the "Windows 2000 Resource Kit", it includes forfiles IIRC.
Related videos on Youtube
Hayri Uğur Koltuk
Updated on September 18, 2022Comments
-
Hayri Uğur Koltuk almost 2 years
I have to write a batch file to delete the oldest file in a folder, but i don't know how to get the name of the oldest file.
I can sort files with DIR,
DIR /B /O:D /T:C
but this is a list and i need the first file (since it sorts the oldest first) in that list.How can I do it?
Thanks