Auto delete in command prompt

Hi guys. there's a folder that users scan things into. however this folder needs to be cleaned up on a regular basis. to do this, I have created a .bat file that will clear up all of the documents in that folder. there is also an auto answer of yes so that when it prompts, it automatically replies yes. however, I'd like this to delete items say 2 weeks old and older. is there a way to do this?
Thanks
4 answers Last reply
More about auto delete command prompt
  1. daniel508 said:
    Hi guys. there's a folder that users scan things into. however this folder needs to be cleaned up on a regular basis. to do this, I have created a .bat file that will clear up all of the documents in that folder. there is also an auto answer of yes so that when it prompts, it automatically replies yes. however, I'd like this to delete items say 2 weeks old and older. is there a way to do this?
    Thanks



    you could use a perl script change DELOLD to how many days old from today say, 120 days old, delete it, 14 days (2 weeks) delete it.

    [cpp]
    #!perl -w
    use strict;
    usage() if (! @ARGV || $ARGV[0] =~ /\D/);
    my $age = $ARGV[0];
    my $dir = $ARGV[1] || '.';
    while (<$dir/*>) { print 'unlink $_' if -M $_ > $age; }

    sub usage {
    print <<'EOF';
    USAGE:
    DELOLD 14 [c:\yourdirhere]
    [/cpp]

    so just save this code into a notepad, (remove the 1. 2. 3. from each line) then save as say.. well call it, cleanup.pl .. now download and install perl

    http://www.activestate.com/activeperl/downloads

    put cleanup.pl in a scheduled task to run every so often or put it in windows startup so it runs each time the computer boots? what ever you prefer
  2. this is going to be put on a server so I don't really want to install anything on there. I was hoping a simple .bat file would suffice?
  3. afraid i dont know enough about batch files to make something that complicated
  4. You can probably put something together from the snippets here.

    http://stackoverflow.com/questions/51054/batch-file-to-delete-files-older-than-n-days

    There were quite a few post that came up when googling for this, and I believe there are a few examples in the above link that do not require installing any other software.
Ask a new question

Read More

Configuration Command Prompt Windows 7