Solved

Batch file for deleting old files more that xx days.

Posted on 2010-08-26
7
386 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
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 54

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 54

Expert Comment

by:Bill Prew
ID: 33542049
Welcome.

~bp
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
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 …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

713 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