Solved

Batch file for deleting old files more that xx days.

Posted on 2010-08-26
7
382 Views
Last Modified: 2012-05-10
Hi Experts,

I required a batch file which runs automatically and move old file more than 10 days to archive folder and then delete after 30 days from the archive.

Thanks
Sobitharaj.S
0
Comment
Question by:sobitharaj
7 Comments
 

Expert Comment

by:halby29
ID: 33538975
0
 
LVL 3

Author Comment

by:sobitharaj
ID: 33539024
Can you please send provide the batch file.
Iam confused on the link provided by you.

I required two batch files.
1. Move files older than 4 days from one folder to another folder.
2. Delete files from Archived folder older than 15 days.

Thanks
0
 
LVL 4

Expert Comment

by:goyal_251
ID: 33539074
Please let us know souce and destination location of the folder
0
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
LVL 3

Author Comment

by:sobitharaj
ID: 33539097
Source folder - C:\IN
Destination Folder: D:\Archived
(First 4 days older file needs to be move automatically to D:\archived folder and then files older than 15 days will get deleted from D:\archive folder)
0
 
LVL 53

Accepted Solution

by:
Bill Prew earned 250 total points
ID: 33540810
This sounds like a job for ROBOCOPY to me.  You can do this easily with just two lines using it.  Something like:

@echo off
set BaseDir=c:\in
set SaveDir=d:\archived
set TempDir=d:\_delete
robocopy "%BaseDir%" "%SaveDir%" /minage:4
robocopy "%SaveDir%" "%TempDir%" /move /minage:15
rmdir /q /s "%TempDir%"

If you don't have a copy of ROBOCOPY it is available as part of this download:

http://technet.microsoft.com/en-us/magazine/2006.11.utilityspotlight.aspx

There are other useful command line options you might want to explore, here is some additional info:

http://technet.microsoft.com/en-us/library/cc733145%28WS.10%29.aspx
http://ss64.com/nt/robocopy.html

~bp
0
 
LVL 3

Author Closing Comment

by:sobitharaj
ID: 33541803
My Problem Got resolved, Thanks
0
 
LVL 53

Expert Comment

by:Bill Prew
ID: 33542049
Welcome.

~bp
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

856 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