Skip to content

Instantly share code, notes, and snippets.

@musantro
Last active August 1, 2016 09:55
Show Gist options
  • Save musantro/c6c0215e3c32ef701ee42301b7c87824 to your computer and use it in GitHub Desktop.
Save musantro/c6c0215e3c32ef701ee42301b7c87824 to your computer and use it in GitHub Desktop.
This script deletes all files and folders older than 15 days fron an specific destination folder.
@echo off
:: set folder path
set dump_path=E:\musan\Downloads\Contenedor
:: set min age of files and folders to delete
set max_days=15
:: remove files from %dump_path%
forfiles -p %dump_path% -m *.* -d -%max_days% -c "cmd /c del /q @path"
:: remove sub directories from %dump_path%
forfiles -p %dump_path% -d -%max_days% -c "cmd /c IF @isdir == TRUE rd /S /Q @path"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment