Using the WSH FileSystem ObjectThe following example script shows how the FileSystemObject can be used to manipulate files and folders. The FolderExists method is used to check if the backup folder already exists. If not, the CreateFolder method is used to create it. The FileExists method is used to see if a particular file exists. If the desired file exists, it is copied with the CopyFile method. Similarly, the CopyFolder method is used to copy an entire folder. Note that the file names are built up by concatenating various strings with the & operator.
Further Details on FileSystemObjectThere is much more that can be done with the FileSystemObject. It gives access to drives, folders, and files. You can move, copy, and delete files and folders. You can get information such as the amount of free space left on a given drive and the time stamp on a file, you can read and write lines of a text file, etc. For further information see the MSDN FileSystemObject page. Back to main Windows Script Host page |