?
Solved

Batch file for deleting old files more that xx days.

Posted on 2010-08-26
7
Medium Priority
?
390 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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 56

Accepted Solution

by:
Bill Prew earned 1000 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 56

Expert Comment

by:Bill Prew
ID: 33542049
Welcome.

~bp
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

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 …
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

777 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