Reputation: 3288
i want to delete files using batch script, the files which are older than 1 day, i want to set the date parameter in the script how can I do that?
for /F "tokens=1 delims=/ " %%a in ('DATE/T') do set dateDOW=%%a
this statemenet is setting the DATE parameter to 7 days ie. if today is wed it will remove files from the last wed.
Thanks in advance
Upvotes: 0
Views: 144
Reputation: 70943
@echo off
rem Number of days ago from where to start to delete files
set "deleteFrom=7"
forfiles /p "c:\somewhere" /m "*.log" /d -%deleteFrom% /c "cmd /c echo del @path"
Adapt as needed. When list of files is correct, remove echo
to delete the files.
Upvotes: 2
Reputation: 37569
for %%a in (Text.txt) do set "FileDate=%%~ta"
echo %FileDate%
enter for /?
for help.
Upvotes: 0