I want to delete folders and its files were created longer than 7 days using the command line.
migrated from stackoverflow.com Dec 11 '11 at 11:46
This question came from our site for professional and enthusiast programmers.
|show 1 more comment|
If you are using *nix and have find available this should do the trick:
From the manpage for
WINDOWS XP & VISTA
I never work on windows though I got curious to see what command to be the equivalent to the above in a MS-DOS environment. I found Batch file to delete files older than N days here on stackoverflow.
The relevant command (copy+pasted from the previously linked thread):
Syntax has changed a little therefore the updated command is
If you need to deal with space limit issue on a very large file tree (in my case many perforce branches), that sometimes being hanged while running the find and delete process -
Here's a script that I schedule daily to find all directories with specific file ("ChangesLog.txt"), and then Sort all directories found that are older than 2 days, and Remove the first matched directory (each schedule there could be a new match):
Note the requirements: