@echo off setlocal EnableExtensions if not defined TEMP ( echo TEMP is not defined. exit /b 1 ) if not exist "%TEMP%\" ( echo Temp folder not found: %TEMP% exit /b 1 ) echo Files older than 7 days in %TEMP%: forfiles /p "%TEMP%" /m * /d -7 /c "cmd /c if @isdir==FALSE echo @path" 2>nul echo. set "ANSWER=" set /p ANSWER=Delete these files? Type Y to continue: if /i not "%ANSWER%"=="Y" ( echo Cancelled. Nothing deleted. exit /b 0 ) forfiles /p "%TEMP%" /m * /d -7 /c "cmd /c if @isdir==FALSE del /f /q @path" 2>nul echo Done. Some in-use files may remain. exit /b 0