
This is non-destructive code, it will display what would have happened.Ĭhange : if !epoch! LEQ %slice% (echo DELETE %%f ^(%%~tf^)) ELSE echo keep %%f ^(%%~tf^) Set dSource=C:\temp : This is the starting directory to check for files. Set /a strip=day*7 : Change 7 for the number of days to keep.

Ok was bored a bit and came up with this, which contains my version of a poor man's Linux epoch replacement limited for daily usage (no time retention):įor /f "delims=" %%f in ('dir /a-d-h-s /b /s %dSource%') do (
