Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Delete files older than X amount of days.

  • 30-11-2011 12:06PM
    #1
    Registered Users, Registered Users 2 Posts: 7,544 ✭✭✭


    I thought i would share this as i have been looking for a simple solution for a long time.

    Ever wanted to delete files older than a certain number of days. Then the windows command line program "forfiles" is what you're looking for.

    Example:

    forfiles /p E:\LogFiles /d -3 /c "cmd /c del @file"

    /p "directory"
    /d -X (Where X is the amount of days previous to today)
    /c "abc" (where abc is the command you want to execute of the result of the files found.
    @file (this automatically replaces @file with the result of the files found)

    In the above example it will delete all files in E:\LogFiles which are older than 3 days.


Advertisement