MS-DOS code to delete old Files
145 pts.
0
Q:
MS-DOS code to delete old Files
I am using windows XP and need to write a DOS batch (.bat) file that will delete old files from a directory.  This will run on a schedule and will not require human interaction to input any data. My problem is, I am not good at writing batch files. I can do the basic 101 type stuff, but  finding dates and doing date comparison is beyond me. 


Software/Hardware used:
Windows XP
ASKED: Oct 20 2009  3:05 PM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
145 pts.
0
A:
 RATE THIS ANSWER
+1
Click to Vote:
  •   1
  •  0
  • AddThis Social Bookmark Button
Here's a VBScript for this activity.

I like using the ForFiles utility for this purpose.

I found this batch file also. Be sure to test first in a test environment.

@ECHO OFF
IF "%DAY%" == "Monday" GOTO FIRST

:SECOND
forfiles /p d:\FTPData /s /m *.* /d -2 /c "cmd /c del @file : date >= 1 day > NUL"
GOTO END

:FIRST
forfiles /p d:\FTPData /s /m *.* /d -4 /c "cmd /c del @file : date >= 3 days > NUL"
GOTO END

:END


________________________________________________________________________________

Thank you for your response.

I ran the batch file at the DOS prompt and the "forfiles" command is not recognize . I received the below error message;


'forfiles' is not recognized as an internal or external command,operable program or batch file.
Last Answered: Oct 20 2009  5:34 PM GMT by Jutpro   145 pts.
Latest Contributors: Labnuke99   26230 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Troy Tate   0 pts.  |   Oct 20 2009  8:05PM GMT

Click on the forfiles link in the answer above. You will need to download the utility.

 

Jutpro   145 pts.  |   Oct 20 2009  8:40PM GMT

Ok, I had overlooked the link and did not realize I had to do a download.

Thank you Troy and Labnuke99.

 
0