Solved

Batch File

Posted on 2004-08-04
3
698 Views
Last Modified: 2010-04-14
Can anyone help me out with writing a batch file that will delete any .zip files in a specific directory that are older than 2 months?
0
Comment
Question by:rrose987
3 Comments
 
LVL 11

Expert Comment

by:Eric
Comment Utility
0
 
LVL 82

Accepted Solution

by:
oBdA earned 125 total points
Comment Utility
One of the easier ways is to use one of the best copy tools ever, robocopy, for this. robocopy is part of the W2k Resource Kit, and it's part of the downloadable W2k3 Resource Kit as well (the W2k3 RK needs to be installed on an XP or W2k3 machine, but robocopy.exe can then be copied to where you need it). This will save the necessity to calculate the date, which is a messy business, especially with localized versions.
Windows Server 2003 Resource Kit Tools
http://www.microsoft.com/downloads/details.aspx?familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en

This script uses robocopy to move files older than the specified days to a separate folder, then simply delete the files in the other folder.

====8<----[DelOld.cmd]----
@echo off
setlocal
set RootDir=D:\Test
set TempDir=D:\DeleteMe
set FileMask=*.zip
set Days=60

robocopy "%RootDir%" "%TempDir%" "%FileMask%" /minage:%Days% /mov /is /r:3 /w:5
del "%TempDir%\%FileMask%"
====8<----[DelOld.cmd]----
0
 
LVL 7

Expert Comment

by:msice
Comment Utility
I use Perl for this - check this code out works great http://www.winnetmag.com/Article/ArticleID/27332/27332.html you need to have perl installed though - its free and found here http://www.activestate.com/Products/ActivePerl/  
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Active directory user account audit 4 728
auto copy 8 610
Virtualise server 2000 for Hyper V 4 832
P2V conversion for Windows NT 4.0 Server 2 2,162
NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

763 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

5 Experts available now in Live!

Get 1:1 Help Now