Get 3.9% APR, Get Instant Credit - Click here!

PC Magazine

  PC Tech

File Management via Windows Scripting

Introduction

File Management Objects

A General-Purpose File-Deletion Script

A Few Details

Figure 1: File deletion script.

Figure 2: VBScript's File-Handling Objects



X10.com - The SuperSite for Home Automation!

First USA!

 
  Categories
Scripting Languages
Windows 95/NT
Operating Systems

Related Stories:
The Windows Scripting Host
-- Operating Systems 2/10/98

File Management via Windows Scripting
A Few Details

Continued from A General-Purpose File-Deletion Script

One potential problem with using the scripting host for time-consuming processes (like our recursive routine) is worth noting: The scripting host has no truly convenient built-in way to build a window on which you can indicate the progress being made. And since it is not uncommon for a hard disk to have more than 2,000 subfolders, the lack of feedback can be disconcerting. VBScript can create message boxes, of course, but message boxes force the user to click on OK constantly. We'll use instead a method that is part of the Windows Scripting Host and displays a sort of super-message box. This method allows you to build a message box that vanishes after a specified number of seconds have passed--whether or not the user has clicked on it. We'll pop this message box up after every 100 folders are visited and keep it on the screen for 1 second. We'll also include a little loop that makes sure the user really wants to proceed. Note that we've hard-coded the program to start in the root directory of C:. To use the code on another drive or directory, change the following line:

Set TheFolder = FSO.GetFolder("C:\")

to reflect your desired starting point. (Of course, you could also add another input routine that allowed users to set the starting folder.)

Figure 1 shows our completed file-deletion script, which you can download as part of this issue's archive. As you can see, the Windows Scripting Host, together with the script language of your choice, has the potential to automate many mundane tasks on your system.

Next: Figure 1: File deletion script.

Published as Operating Systems in the 6/30/98 issue of PC Magazine.


 SPONSORED LINKS
@Backup   Your Solid Online Backup Plan. Download Now.
Services   9c/MINUTE LONG DISTANCE, 5c/MINUTE ON SUNDAYS!
STORAGE   Quantum means non-stop business, 24 hours a day
Software   X10.com -- The SuperSite for Home Automation
Books   Bargain Books up to 90% off at barnesandnoble.com
 ZDNET FEATURED LINKS
Downloads   Check out the best new downloads in Reviewer's Raves
Bargains!   Shop the Basement for best buys on computer products
Free Help   Got computing questions? ZDHelp has all the answers!
 MAGAZINE OFFERS
Free Offer   Get a FREE SUBSCRIPTION to Inter@ctive Week

TOP
Copyright (c) 1998 Ziff-Davis Inc.