Link to home
Start Free TrialLog in
Avatar of tenover
tenoverFlag for United States of America

asked on

I need an Auto-Delete script...FAST.

I know nothing about scripting, and I need an Auto-Delete script that will go through 5 or 6 directories on a single Windows 2000 server and delete any files older than <x> days.  I'd like it to automatically run once a week.  Possible?  How?  Thanks.
ASKER CERTIFIED SOLUTION
Avatar of DVation191
DVation191

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tenover

ASKER

Thanks.  I want to run this on a server weekly and just delete the old files from these 5 directories automatically, I don't want to have to manually move files first....
Avatar of DVation191
DVation191

First of all, it's not a manual operation, as the script does it for you. Secondly, its just a temporary holding place, as the built-in delete command in windows does not support deleting by date. XXCopy actually MOVES the files to the temporary holding place (hence the RC parameter), which subsequently gets deleted with the DEL command.
Avatar of tenover

ASKER

Aahh....Ok, I'll try it out and let you know...Thank you.
Avatar of tenover

ASKER

AWESOME.  That's exactly what I needed.  One thing though, when I ran the .bat file on a couple test folders, I was prompted to copy and to delete all the folders.  As this will be an automated task, do you know off the top of your head if there's a way around the prompting?  Thanks.
Avatar of tenover

ASKER

Nevermind, I found it.  The switch is /YY, instead of /Y.  Thank you very much.
Sure thing! Glad you found it.
Avatar of tenover

ASKER

Last question.....
Can I have one .bat file copy multiple directories over to the same "Destination" folder?  If so, what is the syntax to seprate the source directories?  Thanks.
It's as simple as making the bat file look like this instead:

@ECHO OFF
xxcopy <SOURCE1> <DESTINATION> /Y /RC /DA#<n>
xxcopy <SOURCE2> <DESTINATION> /Y /RC /DA#<n>
xxcopy <SOURCE3> <DESTINATION> /Y /RC /DA#<n>
xxcopy <SOURCE4> <DESTINATION> /Y /RC /DA#<n>
del <DESTINATION>\*.* /s /q
EXIT
Avatar of tenover

ASKER

Yeah, that's what I ended up doing, thank a lot.
Avatar of tenover

ASKER

Does this need to work in a certain directory, or run as a certain user?  It works great when I run it on my test workstation, but when I run the edited file on my 2000 server, it doesn't do anything....I took out the /YY, so I'm getting prompted to copy and delete, but everything is still there.  Ideas?
No, I'm not really sure what is going on...I mean, clearly the script works (we both tested it using current user permissions), so I'd have to conclude that this is a permissions problem, or possibly, an error in the script. Did you copy the script exactly? Pay attention to the trailing "\" on directories, as it can sometimes make a difference. Otherwise, make sure the scheduled task is running under a user account with the proper permissions.
Avatar of tenover

ASKER

Damn....It was the back slashes at the end of the directories.  Thanks.