Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
The FileSystemObject does not include a direct method for renaming a file. However, in much the same way that a folder can be renamed using the MoveFolder method, files can be renamed using the MoveFile method. To rename a file, call the MoveFile method but leave the file in its current folder.
For example, the script in Listing 4.26 renames ScriptLog.txt to BackupLog.txt. Technically, the script actually moves C:\FSO\ScriptLog.txt to a new path: C:\FSO\BackupLog.txt. The net result, however, is that the file named ScriptLog.txt is now named BackupLog.txt.
Listing 4.26 Renaming a File Using the MoveFile Method
|
|
Send us your feedback | « Previous | Next » |