Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Deleting Oldest Directory
Name: toyotaco01 Date: June 9, 2003 at 21:04:57 Pacific OS: XP Pro CPU/Ram: 1.4 ghz 612mb
Comment:
I have a simple batch program that creates a directory named MMDDYYYY and makes a backup of several files that it puts in that directory. Since I am running out of HD space, I wanted to add a section of code to the beginning of the batch file so that it would delete the oldest directory. (i.e so if the directories were 05252003 05302003 and 06062003 , it would delete the directory named 05252003 ) I'm really new to batch files (and DOS really). Thanks in advance for your help guys
Name: Johan_af Date: June 9, 2003 at 23:13:14 Pacific
Reply:
If you know about batch files, im sure you know dos commands. To delete files in dos, you use the DEL command. Try putting this into the start:
DEL x:\05252003\*.*
this will delete the files in the directory But the name of the directory will still be there when you types dir or wathever.
Sorry about my bad english!
NOTE: X: is the drive letter. Very often C:
0
Response Number 2
Name: toyotaco01 Date: June 10, 2003 at 15:44:00 Pacific
Reply:
Thanks for the reply, but thats not exactly what I was looking for. I was hoping to figure out how to scan through all of the directories to figure out which file was the oldest (i.e. smallest number in the format MMDDYYYY)
0
Response Number 3
Name: Scott Date: July 1, 2003 at 09:03:03 Pacific
Reply:
The code below will do what you need (it will only run on NT, 2000, XP):
The code assumes that your MMDDYYY directories are in c:\Backups.
In case the code wraps lines, it should be in two lines: second line starts with "rd" Also, there are spaces between the /f and the %%i, and between each of the /b, /ad, /o-d.
for /f %%i in ('dir c:\Backups /b /ad /o-d') do set OldestDir=%%i rd /s /q c:\Backups\%OldestDir%
Enjoy!
0
Response Number 4
Name: toyotaco01 Date: July 1, 2003 at 16:56:58 Pacific
Summary: I need to delete the directory "Windows" from DOS. At the C: prompt, I typed erase C:\Windows but it didn't work? I can't remember these old commands. Thanks for the help....
Summary: I am trying to delete a directory that seems to be corrupt, but when I dosdel I am told the directory cannot be deleted. When I try to list the files in the directory, I am told that is not possible....
Summary: with just a simple dos command you can delete windows directory. write the following in command invite: deltree c:\windows a confirmation message will appear, accept the deletion. when it is done you ...