tenover
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
ASKER
Aahh....Ok, I'll try it out and let you know...Thank you.
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.
ASKER
Nevermind, I found it. The switch is /YY, instead of /Y. Thank you very much.
Sure thing! Glad you found it.
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.
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
@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
ASKER
Yeah, that's what I ended up doing, thank a lot.
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.
ASKER
Damn....It was the back slashes at the end of the directories. Thanks.
ASKER