0

Trying to delete files in directories named "archive". I have not been able to figure out how to do this without specifcally entering every directory. There are other directories under the serial number (12345) directory.

Example entries are: .\customer\12345\archive .\customer2\54321\archive

forfiles /p "." /s /m "*.zip" /d -90 -c "cmd /c del @path"

I've looked https://serverfault.com/questions/49614/delete-files-older-than-x-days , https://stackoverflow.com/questions/9746778/ms-dos-batch-delete-old-files-in-directory/9747065#9747065 and https://stackoverflow.com/questions/324267/batch-file-to-delete-files-older-than-a-specified-date/1180746#1180746 to no avail

TIA

1 Answer 1

0

See if this will work for you. I use something similar to clear out logfiles.

forfiles /P C:\pathtofile /S /D -90 /M *.zip /C "cmd /c del @file"
4
  • I have multiple paths, about 800 of them.
    – sau71753
    Dec 29, 2014 at 20:27
  • the /s checks all the sub directories, this command should run from the top level folder and flow down.
    – Optichip
    Dec 29, 2014 at 20:33
  • That will also delete files in the \customer\12345\data and \customer\12345\processing folders.
    – sau71753
    Dec 29, 2014 at 20:42
  • Odd this is a Windows command not a linux/unix one, not sure why it got migrated here.
    – Optichip
    Dec 30, 2014 at 18:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy