@echo off set d=%date:~0,10% mshta vbscript:createobject("scripting.filesystemobject").opentextfile("wind.txt",2,true).writeline(dateadd("d",-2,"%d%"))(window.close) for /f %%m in (wind.txt) do (set tt=%%m) set ph=D:/Test for /r "%ph%" %%i in (*) do (if %%~ti lss %tt% (@echo "%%~ti" del /a /f /s /q "%%i")) pause