delete files older than 30 days

I would like to run a batch job to delete all files older than 30 days from the following directory:
Creating a log of file names that have been deleted and storing the log

Can someone please provide the appropriate script for Windows Server 2003?
Who is Participating?
Kieran_BurnsConnect With a Mentor Commented:
Slight amendment

md d:\purgefolder
robocopy D:\ImportData\Customer\Database\source\Archive d:\purgefolder /s /mov /minage:30 /log:D:\ImportData\Customer\Database\source\Logs\logfile.txt

del d:\purgefolder /q/s
the /v was verbose output and thyis was echoed to the log file but the above is cleaner
the /s searches sub-folders (not bothered with /e as you dont need to move empty folders (unless you want to)
/move move the files out
/minage only moves files older than 30 days
I think that covers everything
Robocopy is your friend for this (go download it)
syntax would be something like:
md d:\purgefolder
robocopy D:\ImportData\Customer\Database\source\Archive d:\purgefolder /s /mov /minage:30 /v >>D:\ImportData\Customer\Database\source\Logs\purgelog.txt

deltree d:\purgefolder

ZSLLCAuthor Commented:
Sorry but this does not address the entire question.
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Which bit do you think is missing?
Okay, for 30 points I'm going to say 'Robocpoy'. No more!
ZSLLCAuthor Commented:
OK.  Obviously I don't know how to play the game.  Thanks for your help.
QlemoBatchelor and DeveloperCommented:
*very fat grin*, I got YOU recommending RoboCopy?
Yeah, I thought I never would but... well, it was a 'points'-thing... although, if i come across an interesting challenge I'd answer if for no points.

Oh, and thanks for mentioning me and the 'EndLocal & set...' thing in another thread..

Anyway, it was a nice little earner for Kieran_Burns.... and I think ZSLLC learned something too - and I'm not just refering to Robocopy...

Have a cracking day :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.