Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

delete files older than 30 days

Posted on 2009-06-30
8
Medium Priority
?
511 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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
LVL 10

Accepted Solution

by:
Kieran_Burns earned 150 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 71

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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

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…
This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

618 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