troubleshooting Question

How do I edit my batch file so it leaves a certain amount of days of daily files?

Avatar of Bert2005
Bert2005Flag for United States of America asked on
Windows Batch
3 Comments1 Solution59 ViewsLast Modified:
I have written a batch file, which used to work on a previous server with a similar path. This one is changed to reflect the new path.

E:\Program Files (x86)\Amazing Charts\Backup

forfiles /p "E:\Program Files (x86)\Amazing Charts\Backup" /s /m *.* /c "cmd /c Del @path" /D -3

This work fine,  but it deletes all of the files in the Backup folder. It doesn't leave three.

forfiles /p "E:\Program Files (x86)\Amazing Charts\Backup" /s /m *.* /d -3 /c "cmd /c Del @path"

This one also works, it just wipes out all of them.

It is clearly that the part of the batch file telling Windows to leave three files is not working properly.

Any help would be appreciated.

Bert
ASKER CERTIFIED SOLUTION
NVIT
End-user support

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros