Solved

Batch file for deleting old files more that xx days.

Posted on 2010-08-26
7
389 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
[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
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
Raise the IQ of Your IT Alerts

From IT major incidents to manufacturing line slowdowns, every business process generates insights that need to reach the people required to take action. You need a platform that integrates with your business tools to create fully enabled DevOps toolchains.

You need xMatters.

 
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 55

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 55

Expert Comment

by:Bill Prew
ID: 33542049
Welcome.

~bp
0

Featured Post

Turn Insights Into Action

You’ve already invested in ITSM tools, chat applications, automation utilities, and more. Fortify these solutions with intelligent communications so you can drive business processes forward.

With xMatters, you'll never miss a beat.

Question has a verified solution.

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

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 …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

690 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