@echo off
for /f "tokens=* delims=" %%# in ('FileDateFilterJS.bat "." -hh -5') do (
echo deleting "%%~f#"
echo del /q /f "%%~f#"
)
pause
Replace "." with your Working directory
Here is the FileDateFilterJS.bat given by npocmaka
https://github.com/npocmaka/batch.scripts/blob/master/hybrids/.net/FileTimeFilerJS.bat
IF this does not work give the below code a shot although the above code works for me the below code will work for number of days and not hours.
forfiles -p "C:\what\ever" -s -m *.* /D -<number of days> /C "cmd /c del @path"
Batch file to delete files older than N days
Note that if you want files OLDER than 10 days, you need to specify -d
"-10". -ve means "older than", +ve means "newer than". You can also
specify DDMMYY or -DDMMYY format as the parameter to -d.
If you don't have forfiles installed on your machine, copy it from any
Windows Server 2003 to your Windows XP machine at %WinDir%\system32.
This is possible since the EXE is fully compatible between Windows
Server 2003 and Windows XP.
Batch file to delete files older than N hours or minutes
This might help too.
Hope I helped.