FileSystem Object

The default WSH scripting languages (VBScript and JScript) do not have any native file manipulation capabilities. This functionality is provided by the COM object FileSystem.

The FileSystem object (FSO) exposes a number of separate objects that provide the ability to perform file-related operations. Table 9-18 lists the objects exposed by the FileSystem component

Table 9-18. FileSystem objects

Object

Description

Folders

A collection that contains a list of folders for a specified folder

Folder

Exposes folder information such as size, attributes, and date information and methods to move, delete, and copy

Files

A collection that contains a list of files for a specified folder

File

Exposes file information such as size, attributes, and date information and methods to move, delete, and copy

Drives

Collection object that contains a list of available drives on the local machine

Drive

Exposes drive information, such as size and type

TextStream

Provides text file manipulation

The FSO exposes methods and properties that perform file manipulation operations. Before you can reference any of the objects listed in Table 9-18, you must create an instance of the FSO object:

'create an instance of an FSO object
Set objFSO = CreateObject("Scripting.FileSystemObject")

The FSO object exposes a number of file manipulation methods and properties. The following commands are a few of the most useful FSO-related methods and properties. See “Additional Resources,” ...

Get Windows XP in a Nutshell, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.