Solved

Batch file for deleting old files more that xx days.

Posted on 2010-08-26
7
378 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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 51

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 51

Expert Comment

by:Bill Prew
ID: 33542049
Welcome.

~bp
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
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 seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now