Use This Script to Rename Multiple Files at Once in Windows
You’ll save yourself boatloads of time
Do you need to rename several files at once in Windows? It can be quite the task to do it manually, but Windows supports scripts that you can run to automate the renaming process, saving you loads of time.
As an example, consider a case like in the example image above where you have a folder of hundreds of images each namedCopy ofand then a word or two, likeCopy of Black Tea.jpg.
Instead of manually renaming each file to delete “Copy of” or to change those words to something else, you could run a script to do all the renaming for you.
Software programs and cameras often append a specific set of characters to exported files, so this script comes in handy in those circumstances.
How to Make the Renaming Script
A script is essentially a carefully crafted set of commands to tell the computer exactly what to do. Here’s the “find and replace” script we’re dealing with:
Set objFso = CreateObject(“Scripting.FileSystemObject”)
Set Folder = objFSO.GetFolder(“ENTER\PATH\HERE”)
For Each File In Folder.Files
sNewFile = File.Name
sNewFile = Replace(sNewFile,”ORIGINAL”,”REPLACEMENT”)
if (sNewFile<>File.Name) then
File.Move(File.ParentFolder+”\”+sNewFile)
end if
Next
To use this script requires a text editor. Notepad, built-in to Windows, will do just fine.
Step 1: Open Notepad. You can do this by searching forNotepadin the Start menu or by executing thenotepadcommand in the Run dialog box (WIN+R).
Step 2: Copy the script exactly as it’s shown above, and paste it into Notepad.
Step 3: Edit the file rename script to make it apply to your unique situation.
To do that, you need to change the text calledENTER\PATH\HEREto the exact folder where your soon-to-be-renamed files are located.
For example, maybe you want to rename a group of files in a folder on your desktop, in which case your folder path might look like this:C:\Users\Matt\Desktop\Converted MP3s.
To make the script always apply to the folder it’s currently located in, just change the path to.. That is, a period and then a backslash, without a space. Using the script this way lets you drop it into any folder and have it automatically apply to only that folder.
Also changeORIGINALto the characters you want to replace, and deleteREPLACEMENTso that you can enter the text that should replace the original characters. In other words, you can read this line of the script as “replace THIS with THIS.”
Note: Make sure you keep the quotes in every instance you see them. They need to remain in the folder path and the replace section.
Step 4: Go toFile>Save Asand name the file anything you like, but be sure to change the “Save as type” option toAll Files (*)and append.vbsto the end of the file name.
Step 5: You can now close out of Notepad and execute the VBS file to apply the script.
That’s it! To edit the VBS file to change the location of the files to rename, or to adjust what to replace in the files, just right-click the VBS file like you see above, but instead of opening it, chooseEdit.
How
to Bulk Rename Files in Windows 10
If you’re using Windows 10, there’s a built-in renaming feature that’s easy to use and might be exactly what you’re after. This method is unique compared to the script above because it works even if the files have completely different filenames.
In other words, these two methods have completely different use cases. Let’s say you have 100 files that each have the wordhousein them along with other random characters. You want to keep all the characters untouched but make the word house intohome. The script is great for that.
However, if the 100 files are all named random characters and you want them to be really similar likehousepics, you can use the Windows 10 renaming function to rename the first tohousepics (1), the second tohousepics (2), the third tohousepics (3), and so on.
Here’s how to do this in Windows 10:
Step 1: Highlight the files you want to rename.
Step 2: Press theF2key or right-click one of the selected files and chooseRename.
Step 3: Type the filename you want to use and then pressEnter.
Instantly, every selected file will use the exact same filename. If each file is using a different file extension, they’ll all be named identically, but if they have the same file extension, a number will be appended to the end since two or more files can’t use the same filename in the same folder.
Founder of Help Desk Geek and managing editor. He began blogging in 2007 and quit his job in 2010 to blog full-time. He has over 15 years of industry experience in IT and holds several technical certifications.Read Aseem’s Full Bio
Leave a Reply
Your email address will not be published.Required fields are marked*
Comment*
Name*
Email*
Website
Welcome to Help Desk Geek- a blog full of tech tips from trusted tech experts. We have thousands of articles and guides to help you troubleshoot any issue. Our articles have been read over 150 million times since we launched in 2008.
HomeAbout UsEditorial StandardsContact UsTerms of Use
Copyright © 2008-2024 Help Desk Geek.com, LLC All Rights Reserved