Hi
i use a .cmd file to delete all files older than 20days in a drive.
set PFAD=T:\
set TAGE=20
forfiles -p %PFAD% -s -m *.* /D -%TAGE% /C "cmd /c del /Q /F @path"
the problem is that this use the modification date of the file.
is it possible to delete files with the last access is older than 20 days?
because if i copy a file in the drive the modification time don't change.
sorry for the bad english and i hope someone can help me.
greets steff
last access file
Moderator: DosItHelp
Re: last access file
ROBOCOPY with options /L and /MINLAD:20 may help to select the files. If you process the output in a FOR /F loop you can perform the deletion.
Note that the FOR /F loop buffers the whole output of ROBOCOPY in memory before it even begins to iterate. That will take as much time as it takes to process each file on you drive.
Remove the ECHO if you are sure the right files were found.
Regards
aGerman
Code: Select all
for /f "tokens=*" %%i in (
'robocopy "T:\." "T:\." /l /s /xx /is /it /nc /ns /np /ndl /njh /njs /r:0 /w:0 /minlad:20'
) do ECHO del /f "%%i"
Note that the FOR /F loop buffers the whole output of ROBOCOPY in memory before it even begins to iterate. That will take as much time as it takes to process each file on you drive.
Remove the ECHO if you are sure the right files were found.
Regards
aGerman
Re: last access file
hey aGerman
thanks a lot it works perfekt.
oder auf deutsch...
besten dank... es funktioniert einwandfrei
thanks a lot it works perfekt.
oder auf deutsch...
besten dank... es funktioniert einwandfrei
Re: last access file
Good to hear
BTW: Based on your variable names I already figured that your mother tongue is German too
BTW: Based on your variable names I already figured that your mother tongue is German too