Skip to content

Instantly share code, notes, and snippets.

@derekmurawsky
Created February 25, 2014 14:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save derekmurawsky/9210118 to your computer and use it in GitHub Desktop.
Save derekmurawsky/9210118 to your computer and use it in GitHub Desktop.
A simple way to delete files older than X days in windows. This command is native and works as far back as server 2003.
REM Deletes files in specified path older than X days.
forfiles -p "C:\path\to\files" -s -m *.* -d -360 -c "cmd /c del @path"
REM Alternate way to do it. Deletes all files in current directory older than X days.
forfiles -s -m *.* -d -360 -c "cmd /c del @path"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment