0

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

3 Answers 3

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.

1

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.

0

would be sooo easy with gnu userspace apps for windows. :)

You might want to check it out if you have a possibility to install tools on the machine in question.

http://getgnuwin32.sourceforge.net/

Sourceforge currently has some guru meditation issues, but hope the link works.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .