SunQuest
 
       Windows Scripting
  Home arrow Windows Scripting arrow An Introduction to Files and Folders in WS...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
VeriSign Whitepapers 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WINDOWS SCRIPTING

An Introduction to Files and Folders in WSH
By: Nilpo/Developer Shed Staff Writer
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 4
    2007-02-05

    Table of Contents:
  • An Introduction to Files and Folders in WSH
  • Enumerating Files and Folders
  • Working with Files and Folders
  • Using the Sub-Objects
  • Using What You’ve Learned

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    An Introduction to Files and Folders in WSH


    (Page 1 of 5 )

    In this series of articles we’ll take a close look at dealing with files and folders in WSH. There are a few different ways to do this. First we’re going to take a look at WSH’s native way of doing this by using the FileSystemObject.

    The FilesSystemObject is VBScript’s way of working directly with the file system.  It provides methods and properties for handling and manipulating files and folders.  You can create, move, and delete files and folders as well as check and change some attributes.

    You should already be familiar with connecting to the FileSystemObject.  In VBScript it looks like this:

    Set objFso = CreateObject("Scripting.FileSystemObject")

    The above code uses the Wscript object’s CreateObject method to get a handle on the FileSystemObject.  The beauty of the FileSystemObject is that the ActiveX control can automatically detect the type of file system and work with it.  The FileSystemObject can work with any file system supported on your system.

    The FileSystemObject works with the native drivers to control the file system.  That means if you were to add support for some non-Windows file system such as ext3, then the FileSystemObject would support it inherently.

    Keep in mind when creating scripts that deal with the file system, sometimes these processes can take a while.  It’s not unusual to take up to 10 minutes or more to enumerate the files and folders on a typical drive that is near capacity.  Of course, there are a lot of factors that play into this: drive seek speed, bus speed, processor speed, available memory, and background processes just to name a few.  Some files systems are faster than others simply by design.

    In short, a little error-handling and some pre-design thought can go a long way.

    Before diving into your script, you should also take a couple other things into consideration.  Will your script be running locally or remotely?  And will you be using this script on multiple hosts or always running it from the same location?  These things can affect the way that you handle folder paths.  We’ll deal more with these later.

    More Windows Scripting Articles
    More By Nilpo/Developer Shed Staff Writer


       · VBScript's FileSystemObject provides a very useful interface for accessing files and...
     

    WINDOWS SCRIPTING ARTICLES

    - Generating Outlook Signatures Based on Activ...
    - VBScript: Converting and Formatting with Fun...
    - VBScript: Conversion and Format Functions
    - VBScript: Array Functions
    - VBScript: Strings, You Can`t Function withou...
    - VBScript: More String Functions
    - VBScript: Functioning with Strings
    - Working with the Windows Registry in C++
    - Understanding Objects
    - HTML Applications: Giving WSH a User Interfa...
    - Modifying Computer Objects with Active Direc...
    - Logon Script to Send Email Notifications
    - Securing Computers and Active Directory
    - Moving and Renaming Computers with Active Di...
    - Working with System Processes in WSH





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway