Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


June 27, 2007

Automatically Delete Old Folders


RSS
View this exclusive article with VIP access -- click here to join |
See More Systems Administration Articles Here | Reprints | Or sign up for our VIP Monthly Pass!

In "Automatically Delete Old Files", I discuss DelFile.vbs, a script that you can use to delete files based on their last modified date. This script works well in deleting files in specific folders. However, my administrators wanted an additional tool to delete entire folders that were no longer used. So, I wrote the DelFolder.vbs script. DelFolder.vbs loops through all the folders in the specified root directory and deletes folders (and their contents, including subfolders) based on their last modified date. This script is useful for deleting folders that users create, then forget about. In our organization, this situation often occurs on network drives.

To use DelFolder.vbs, you need to run the script using the CScript host. The command syntax is

delfolder.vbs drive
 days_since_last_modified
 delete(0)_or_display(1) 

where drive is the root directory you want to check. You use the days_since_last_modified argument to specify the number of days you'll allow since the last modified date. You use the last parameter to indicate whether you want to just display the folders (specify a value of 1, which is the default) or actually delete the folders (specify a value of 0). For example, if you want to preview folders on the D drive that haven’t been modified for at least 14 days, you'd use the command

 delfolder.vbs D:\ 14 1 

To delete those folders, you'd change the last parameter to 0: . . .

Reader Comments

You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

The website is down because someone removed the X-Box

What happens when a manager mistakes a server for a games console. ...

Microsoft Kills OneCare, Will Launch Free Security Solution

Microsoft on Tuesday announced that it would retire its $50-a-year security subscription product, Windows Live OneCare, and replace it with a free solution codenamed "Morro." Unlike OneCare, however, Morro will focus only on core anti-malware features and ...


Task Automation Whitepapers Essential Guide to E-discovery and Recovery for Microsoft Exchange

Continuous Data Protection and Recovery for Microsoft Exchange

Protecting (You and) Your Data with Exchange Server 2007

Related Events SQL Server 2008 – Can You Wait? | Philadelphia

SQL Server 2008 – Can You Wait? | Atlanta

SQL Server 2008 – Can You Wait? | Chicago

Check out our list of Free Email Newsletters!

Task Automation eBooks Spam Fighting and Email Security for the 21st Century

A Guide to Windows Certification and Public Keys

Keeping Your Business Safe from Attack: Patch Management

Related Task Automation Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing