need to delete files in specific folders that exceed 3 days in age

cliffordgormley
cliffordgormley used Ask the Experts™
on
Hello,
Windows 7
I need to delete files in specific folders that exceed 3 days in age.
What is a good automated way to do this?

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Distinguished Expert 2018
Commented:
Hi.

There's an onboard executable to deal with file ages and commands based on file ages: forfiles.exe. Open a command prompt and enter forfiles /?
With the right syntax, you can setup a scheduled task that uses forfiles each day.

If you need further help, come back.
forfiles -p "C:\yourfolder\" -s -m *.* -d 3 -c "cmd /c del @path"

you can get this running with task schedular so that it runs automatically.
Distinguished Expert 2018

Commented:
@anuroopsundd
Could it be that you repeated my comment unintentionally?

Author

Commented:
Hello
I am getting the following error message.

D:\cliff\Documents\CliffFilezillaVideo>forfiles -p "D:\cliff\Documents\CliffFilezillaVideo\" -s -m *.* -d 3 -c "cmd /c del @path
ERROR: Invalid argument/option - '@path'.

Thanks!
Distinguished Expert 2018

Commented:
It's always useful to read the manual thoroughly :)
Try
FORFILES /P D:\cliff\Documents\CliffFilezillaVideo /S /d +03 /C "cmd /c del @path"

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial