How do I Rename Files With a VBS Script?

Written by jim campbell
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How do I Rename Files With a VBS Script?
Change a file name using VBS code. (computer image by Orlando Florin Rosu from

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


  1. 1

    Click the Windows "Start" button and select "All Programs." Click "Accessories" and then click "Notepad." This opens a new editor window.

  2. 2

    Enter the following code into your Notepad editor:

    Dim rename_file

    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."

  3. 3

    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.

  4. 4

    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.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.