Solved

delete files older than 30 days

Posted on 2009-06-30
8
500 Views
Last Modified: 2012-05-07
I would like to run a batch job to delete all files older than 30 days from the following directory:
D:\ImportData\Customer\Database\source\Archive
Creating a log of file names that have been deleted and storing the log
D:\ImportData\Customer\Database\source\Logs

Can someone please provide the appropriate script for Windows Server 2003?
0
Comment
Question by:ZSLLC
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 10

Expert Comment

by:Kieran_Burns
Comment Utility
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

0
 

Author Comment

by:ZSLLC
Comment Utility
Sorry but this does not address the entire question.
0
 
LVL 10

Expert Comment

by:Kieran_Burns
Comment Utility
Which bit do you think is missing?
0
 
LVL 10

Accepted Solution

by:
Kieran_Burns earned 50 total points
Comment Utility
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
 
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 16

Expert Comment

by:t0t0
Comment Utility
Okay, for 30 points I'm going to say 'Robocpoy'. No more!
0
 

Author Comment

by:ZSLLC
Comment Utility
OK.  Obviously I don't know how to play the game.  Thanks for your help.
0
 
LVL 68

Expert Comment

by:Qlemo
Comment Utility
t0t0,
*very fat grin*, I got YOU recommending RoboCopy?
0
 
LVL 16

Expert Comment

by:t0t0
Comment Utility
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 :)
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 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

13 Experts available now in Live!

Get 1:1 Help Now