Solved

delete files older than 30 days

Posted on 2009-06-30
8
509 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 10

Expert Comment

by:Kieran_Burns
ID: 24745102
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
ID: 24746020
Sorry but this does not address the entire question.
0
 
LVL 10

Expert Comment

by:Kieran_Burns
ID: 24746040
Which bit do you think is missing?
0
Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

 
LVL 10

Accepted Solution

by:
Kieran_Burns earned 50 total points
ID: 24746157
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
 
LVL 16

Expert Comment

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

Author Comment

by:ZSLLC
ID: 24749715
OK.  Obviously I don't know how to play the game.  Thanks for your help.
0
 
LVL 70

Expert Comment

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

Expert Comment

by:t0t0
ID: 24839752
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…

707 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