I am looking to make a simple batch file that will delete files and sub folders that are older than X days. I hope to schedule it for a daily run with task scheduler.
Windows 8.1
I am looking to make a simple batch file that will delete files and sub folders that are older than X days. I hope to schedule it for a daily run with task scheduler.
Windows 8.1
Check this question. You can use the FileTimeFilterJS.bat or FileDateFilter.bat.They had pretty similar command line options but the first is based on jscript and the second jscript.net (and requires installed .NET Framework).Check the help messages for the details.This will delete files created 5 days ago (you can choose also modified date and last accessed date):
@echo off
for /f "tokens=* delims=" %%# in ('FileDateFilterJS.bat "." -dd -5') do (
echo deleting "%%~f#"
rem remove echo if the listed files are the ones you need
echo del /q /f "%%~f#"
)
pause