Home > Uncategorized > Delete old files from commandline

Delete old files from commandline

August 12, 2013

To quickly run a command (like delete) on files older than X days in commandprompt:

forfiles -p “C:\folder\Subfolder” -s -m *.* -d (Number of days) -c “cmd /c (command) @PATH”

Number of days has to be negative for days in the past (for example -30 for 30 days old). Replace “command” with the command you want to run (like del or echo)  

%d bloggers like this: