0

what is the CMD command to delete the files which is two days older from a particular folder when we run a batch file?

0

2 Answers 2

1

You could use FORFILES command together with DEL: FORFILES has an option to filter files older than x days and than execute another command on filtered files.

forfiles /P "path you want to search files" /S /D -2 /C "cmd /c del @file" 

FORFILES is a native command under Vista/Windows7/2008, you can get it from the Resource Kit for Windows XP. Note that the syntax may change a little depending on version of FORFILES you're using.

Sign up to request clarification or add additional context in comments.

Comments

0

You could use the fileDate variable, and compare it to the current date, then if it is 2 days or older, you run the eraser over it?

2 Comments

Let's say you test a file named "Bacon.egg". You use the fileDate variable, check if it's old enough, then use the DEL command : DEL bacon.egg
Easier said than done. It can be done, but your answer does not explain how.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.