Gabriel Antunes
Gabriel Antunes

Reputation: 1

How to delete files for date with script

I have a script for deleting files, folders and subfolders, but I will want delete for date, 1 days ago for example, I add in my script these parameters "/D -1 or /D +01 or D/ +1" but isn't run.

Below is my script:

del /q "C:\Users\gabrielp3081_00\Documents\new\*"
FOR /D +01 %%p IN ("C:\Users\gabrielp3081_00\Documents\new\*") DO rmdir "%%p" /s /q 
exit

Upvotes: 0

Views: 192

Answers (1)

wasif
wasif

Reputation: 15518

To delete the files that were modified 1 day ago use this:

& "C:\Windows\System32\forfiles.exe" /p "FilePath" /s /m *.* /d -1 /c "cmd /c del @path"

Upvotes: 1

Related Questions