Solved

Batch File

Posted on 2004-08-04
3
715 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
[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
3 Comments
 
LVL 11

Expert Comment

by:Eric
ID: 11719940
0
 
LVL 85

Accepted Solution

by:
oBdA earned 125 total points
ID: 11720645
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
ID: 11720677
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

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

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

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…
Resolving an irritating Remote Desktop connection that stops your saved credentials from being used.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
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…

695 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