Visual Basic Scripting (VBS) is a language used by system administrators to automate tasks such as renaming files. The administrator creates a VBS file in a simple text editor such as Windows Notepad. The VBS language is a lightweight version of Visual Basic (VB), so administrators familiar with the full VB language easily develop VBS files for the client network computers. Writing a script to change file names only takes a few lines of code.
- Skill level:
Other People Are Reading
Click the Windows "Start" button and select "All Programs." Click "Accessories" and then click "Notepad." This opens a new editor window.
Enter the following code into your Notepad editor:
Set rename_file = CreateObject("Scripting.FileSystemObject")
rename_file.MoveFile "old_file.txt", "new_file.txt"
The code above first creates a variable called "rename_file." The variable is initialised and set as a file object. The final line of code changes the "old_file.txt" name to the "new_file.txt."
Click the Notepad "File" menu item and select "Save As." Enter "renamefile.vbs" into the file name text box and click "Save." The "VBS" extension indicates to the Windows operating system that the file is an executable.
Double-click the vbs file on your computer. This tests the file's code and changes the name of the target file on your hard drive.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for