What code would I use in a cmd file to delete specific backup files?

Posted on 2011-05-10
Last Modified: 2012-05-11
I have set up  task manager in Windows Server 2008 R2 to back up an Access 2007 DB  every hour, 12 hours/day, every week day.
These files are saved as  .accdb files in  F:\xyz

I need to write a .cmd file that will be triggered by task manager once a day to delete all .accdb files in F:\xyz that are  >  1 day old.
Question by:PDSWSS
    LVL 21
    LVL 51

    Expert Comment

    by:Bill Prew
    If you don't mind using a small free command line utility, take a look at DELAGE32:


    Author Comment

    Any reason (SECURITY) not to set ExecutionPolicy in Windows Powershell to Remote Signed- Thanks

    Assisted Solution

    I was not clear enough in my question. I need to delete the folders that contain the backup files not just the files.  Thanks

    Accepted Solution

    LVL 2

    Expert Comment

    A simple way might be moving the older files to a new folder and then deleting them, for example,

    @Echo off
    md F:\xyz\Olderfiles
    robocopy "F:\xyz" "F:\xyz\Olderfiles" *.accdb /e /v /r:2 /w:0 /mov /MINAGE:1
    RD /S /Q "F:\xyz\Olderfiles"

    Author Closing Comment

    None of the answers provided by the experts answered the question as I needed it to be answered. Therefore, I reposted and made it clearer what I was looking for. I received an excellent answer in the repost. Thanks

    Featured Post

    Want to promote your upcoming event?

    Attending an event? Speaking at a conference? Or exhibiting at a tradeshow? Easily inform your contacts by using a promotional banner in your email signature. This will ensure your organization’s most important contacts are in the know.

    Join & Write a Comment

    Create your own, high-performance VM backup appliance by installing NAKIVO Backup & Replication directly onto a Synology NAS!
    New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
    This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
    This tutorial will walk an individual through the process of installing the necessary services and then configuring a Windows Server 2012 system as an iSCSI target. To install the necessary roles, go to Server Manager, and select Add Roles and Featu…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now