Get IT Solutions

How to do IT
Menu
  • Home
  • SCCM 2012
    • Deploy Packages
    • Troubleshooting errors SCCM 2012
  • Windows
    • Applications Silent Install
    • Windows Tools
    • Windows Error
    • Script
    • Exchange Server
    • Troubleshooting Office
    • Applications Errors
  • Database
    • SQL Server
    • MySQL
    • Oracle
  • Cybersecurity
  • Other
  • Reviews

Batch rename multiple files in folder – CMD script – Bulk Method – Win 10

The following article will teach how to rename multiple files in a folder with the bulk method using Command Line (CMD). Besides the CMD, we will show how you can do it using Powershell and VBS Script. Together with them, we will play using some tricks like how to trim multiple names or add a prefix to file names. Just in case if you want to do this for a single file check our previous article – “script rename file using Command Line”.

Bulk File Rename on Windows

Use Windows Explorer to rename files

Before we move to the commands ant batch, let’s see how we can rename multiple files at once in bulk using file explore.

You can simply use Windows Explorer to rename files If you don’t have a fancy renaming task at hand, or don’t want to install anything.

  1. Copy all the files which you want to rename, in a single folder.
  2. Highlight each file which you want to rename. Press Ctrl+A to highlight them all, if not, then press and hold Ctrl and click on each file you want to highlight.
  3. Once all the files are highlighted, right-click on the first file and click on “Rename” (press F2 to rename the file without making more actions).

Note! Arrange them properly if you want to provide any specific order. Do this task before renaming. The renaming process will start from the first selected file and end on the last with proper numbering sequence.

  1. Just enter the name which you would like to give and press enter. All the files will be given the same name with a numbering sequel in the end. It’s a pity that Windows is adding spaces, and ( ) characters in names, instead of having a simple _number option. Below we will teach how you can remove the space and other characters that you don’t want in the naming.

 

How to batch rename multiple files in bulk using CMD

  1. Open Start.
  2. Search for Command Prompt and click the result to open the app.
  3. Type the below command to navigate to the folder where are located the files you want to rename and press Enter:
cd c:\TestPath
  1. Type the following command to rename multiple files in bulk and press Enter:
rename *.FILE-EXTENSION ???-FILE-NAME.*

In the command, the wildcard ”*” tells the rename command to rename everything with a “.txt” extension. The “?” is also a wildcard, but it represents a character of the original file name.

This command example renames all “.txt” files in the target folder leaving the first three letters (which works as a unique identifier to avoid duplication) and appends “-Test1” to the name:

rename *.txt ???-Test1.*

 

How to create a simple batch script to rename all files in a folder

If you are going to automate the above activities or to execute over the network you will need to create a batch file. For example, you need to rename all files in a folder located  on all computers of the network:

  1. Open a notepad file
  2. Copy the below command
@echo off
rename “c:\*.txt” “???-Test1.*”
  1. Save as rename.bat
  2. Execute the file and all the changes will be done

 

Note! On this file, you can change the “rename “c:\*.txt” “???-Test1.*” command with the command you want, based on the task you want to archive described in this article.

You can use the batch files for many other simple actions like to delete files in bulk or to delete folders.

 

How to add a prefix to file names in batch

If you want to add any prefix to file names, it can be done as in the below example. Here we try to add ‘Work’ to every txt file in the current folder and subfolders.

forfiles /S /M *.txt /C "cmd /c rename @file [email protected]"

Similarly, we can add a number to a file name.

forfiles /S /M *.txt /C "cmd /c rename @file [email protected]"

 

How to Handling names with white spaces

If the new name you want to assign to the files has white space within it, it can be done by adding double quotes around the file name. So that forfiles does not misinterpret these double-quotes, you need to escape them with ‘\’

For example, to add ” – pic.txt” to each of the jpg files, the command would be as below.

forfiles /M *.txt /C "cmd /c rename @file \"@fname - pic.txt\""

 

How to create vbs script to rename multiple files in bulk

Consider a case like in the example image above where you have a folder of many images each named Copy of and then a word or two, like Copy 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 vbs script to do all the renaming for you. To create it follow the steps:

  1. Open a notepad file
  2. Copy the below command
Set objFso = CreateObject(“Scripting.FileSystemObject”)
Set Folder = objFSO.GetFolder(“Path”)
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
  1. Edit the file rename script to make it apply to your unique situation.
READ ALSO -   How to create PowerShell scheduled task

You need to change the text called “Path” to the folder name where your soon-to-be-renamed files are located. In our example c:\Test\

To make the script always apply to the folder it’s currently located in, just change the path to .\.

Also, change ORIGINAL to the characters you want to replace, and delete REPLACEMENT so that you can enter the text that should replace the original characters.

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.

  1. Save as rename.vbs
  2. Execute the VBS file to apply the script.

 

How to Trim Multiple Names

Here is how to trim multiple names simultaneously if you want to make the file names shorter.

For instance, you may have .txt files that you need to trim with names that have already been customized. Inside the target directory, you can add the “ren*.* ?????.*” function. This function will trim the original photos to the number of characters designated by the question marks.

This example will turn a file named “test1_test.txt” into “test1.txt” Of course, if the file name is six characters or less in length, it will remain the same. This is useful where short file names are a better option than long ones.

To make long file names shorter with Command Prompt, use these steps:

  1. Open Start.
  2. Search for Command Prompt and click the top result to open the app.
  3. Type the following command example to navigate to the folder with the files you want to rename and press Enter:
cd c:\TestPath
  1. Type the following command to make file names shorter and press Enter:
ren *.* CHARACTER-COUNT.*

In the command, the wildcard “*” matches all the file names and extensions in the folder, and the wildcard “?” indicates how many characters to use for the new file name.

This example trims the file names longer than five characters:

ren *.* ?????.*

If the file name is less than five characters, then the name will not change. (If you want to make the file name longer, add extra question marks.)

Once you complete these steps, you’ll end up with shorter file names depending on the question marks (?) you specified in the command.

 

How to Modify Multiple Names

If you want to rename a specific part of multiple filenames with similar names, here’s how to do it. For example to rename multiple filenames that all start with “Testing_2020” so that they start with “Test_20”

  1. Open Start.
  2. Search for Command Prompt and click the top result to open the app.
  3. Type the following command example to navigate to the folder with the files you want to rename and press Enter:
cd c:\TestPath
  1. Type the following command to make file names shorter and press Enter:
ren Testing_2020*.* Test_20*.*

This is a handy command for shortening file names.

 

How to Change Files with Specific Extensions

Now suppose that you have multiple file types within a folder and you want to rename only the ones with the .txt extension. This is very easy on command Prompt. Let us say that you want to rename all files titled “Testing_2020” to “Test_20,” but only those with the .txt extension. Then, type:

ren Testing_2020*.txt Test_20*.txt.

This command will rename all said filenames, like the one above, but it will only do so for .txt files.

 

How to Change Extensions of multiply files in bulk

Sometimes, you may want to change file extensions for multiple files. You could do this by using the above-mentioned function that allows you to change name parts, but there is an easier way to go about things here.

Once in the desired directory, type in “ren *.txt *.xml” to change all .txt files to .xml files. We have described this better in the following article here.

 

Powershell rename multiple files at once

  1. Open Start.
  1. Search for PowerShell and click the top result to open the app.
  2. Type the following command to rename a single file and press Enter:
Dir | Rename-Item –NewName { $_.name –replace “ “,”_” }
  1. The command replaces blank spaces with underscores (_).

This feature offers the most options, but using this method can by time-consuming, and complicated for beginners, which is why we assume that most users will skip this solution.

There you go, PowerShell is the most powerful tool for renaming multiple files in Windows 10. You can experiment with various options and commands, in case you have some free time, and want to learn more about this tool.

Other PowerShell commands:

To replace open bracket:

 dir | rename-item -NewName {$_.name -replace [Regex]::Escape("("),""}

To replace close bracket:

 dir | rename-item -NewName {$_.name -replace [Regex]::Escape(")"),""}

 

Conclusion:

So those are the trick to save your daily time and to rename multiple files in folder with the bulk methods. Using CMD, Powershell, or VBS Script. Let’s hope that you find and customize your needs.

 

Share
Tweet
Google+
Pinterest
Linkedin
Stumble
Email
Prev Article
Next Article

Related Articles

How to list files in cmd
List files using the cmd tool. Command-line provides a simple …

How to list files in cmd – Command Prompt – Windows 10

How to rename folder in CMD (Command Line)
In this article, we will show you how some quick …

How to rename folder in CMD (Command Line)

Best Computers & Laptops

Best Computer for Cyber Security – Laptop and Desktop
Best Computer for Cyber Security
Hey, are you seeking the best computer for cyber security? Well, we must say you have come to the right place to find your answer and guidance. There are a plethora of products out there for you to pick from ...
Read More
Best Computer for Microsoft Office & Excel – Laptop and Desktop
Best Computer for Microsoft Office & Excel
Are you finding the Best Computer for Microsoft Office and Excel? In modern days, the best laptop or desktop set is the one which is both portable, has good looks and offers the smoothest performance. Microsoft Office is a package ...
Read More
Best Computer for Hacking – Laptop and Desktop Selection
Best computer for Hacking
When it comes to hacking, either laptop or desktop, choosing the best computer for hacking would be an exhilarating job. There are many specifications to be considered for hacking ...
Read More

SQL Server Tips

FIX sqlstate 42000 – mysql error 1064 – you have an error in your sql syntax
Sqlstate 42000 Is a general code that come together with other number. Most often comes with the code 1064 and ...
Read More
The execute permission was denied on the object – SQL Server Error
The execute permission was denied on the object
The following article will handle “the execute permission was denied on the object” error appears on SQL Server. This error ...
Read More
How to Read Data from LDF file in SQL Server – A Complete Guide
Read LDF File
Hello Everyone, Today we are going to address the most popular query of SQL users, how to read data from ...
Read More

Search

We are on:

Get FREE SPACE for your PC

3 Method to Delete Temp Files in Windows 7/10 including vbs script

In this post we will explain how to delete temp files windows 7 using three different methods including vbs script ...
Read More

Fastest way to delete hiberfil sys from windows 10/8/7 and XP – CMD

In this article we will explain how to remove or delete hiberfil sys from Windows 10/8/7 and XP . If you does ...
Read More

Learn How to Silent Install Applications

Silent Install Adobe Flash Player
In this tutorial will explain how to silent install adobe flash player 25, Msi and Exe version. How to disable auto update and uninstall older ...
Read More
Java Silent Install and Uninstall Older Version – Deploy Package MSI
This tutorial will explain how to silent install Java MSI/EXE version and disable auto-update. The command line will also uninstall the ...
Read More
Silent Install Adobe Shockwave Player 12 and disable update
In this tutorial will explain how to silent install Adobe Shockwave Player 12 msi and disable auto update. The command will uninstall older ...
Read More
Silent Install Google Chrome MSI, Silent Uninstall and Disable Auto Update
This tutorial will explain how to silent install Google Chrome MSI and disable auto update. The command will uninstall older version of ...
Read More
Silent Install Adobe Reader 11 and DC – msi and exe – disable update
In this tutorial will explain how to silent install Adobe Reader version 11 and DC. We will user both version "msi" ...
Read More
Silent Install Mozilla Firefox msi and exe file – Including Silent Uninstallation
This tutorial will explain how to silent install Mozilla Firefox. We will use MSI and EXE files to perform a silent ...
Read More
Skype Silent Install Msi and disable updates
In this tutorial will explain how to silent install skype  and disable auto update. The command will uninstall older version of Skype and ...
Read More
Filezilla Silent Install msi and exe version
Filezilla silent install tutorial will explain how to perform a silent installation of application. We will explain methods, silent install ...
Read More
Silent install VLC Media Player
In this tutorial will explain how to silent install VLC Media Player. We will explain both methods for exe and ...
Read More
Notepad++ silent install exe and msi version – Command Line
Notepad++ silent install is the new article from a series of silent installations. Notepad++ as free software has two main ...
Read More

Batch File Solutions

How to list files in cmd – Command Prompt – Windows 10
Whenever you want to search and make a list of all files on a specific folder, you used the windows ...
Read More
Batch rename multiple files in folder – CMD script – Bulk Method – Win 10
The following article will teach how to rename multiple files in a folder with the bulk method using Command Line ...
Read More
Batch script rename file using Command Line (CMD) & PowerShell – Windows 10
The following article will use the “rename” or “ren” command to rename the file using a command prompt. Also, we ...
Read More
Change extension of multiple files at once – CMD batch file
The following article will teach the methods to change the extension of multiple files at once using command prompt and ...
Read More
How to delete registry key with command line | PowerShell | Batch
The following article is the third of series about registry and working on it through command line (CMD) and PowerShell ...
Read More
How to add registry key & values with CMD | PowerShell | Batch
The registry is the place where most of the applications store the settings but not only. Used also from the ...
Read More
Unmap Network Drive CMD – (Batch file) – net use delete command
After we posted the methods to map network drive using cmd commands we come this time with the method to ...
Read More
Map Network Drive cmd (batch file) – net use user password
This article will focus on another way to map a network drive on your computer instead of from the explorer ...
Read More
How to Find Large Files on Windows 7 & 10 – CMD Forfiles Command
If the capacity of your hard drive is running low, it is time to clean off some files and to ...
Read More
CMD Script to check disk space on windows and multiple remote servers
The following article will provide you script to check disk space. The Script monitor space on windows and multiple remote ...
Read More

Get IT Solutions

How to do IT

About Us

Get IT Solutions is a personal blog, which is managed to guide people for various topic.

Second Menu

  • Donate
  • About Us
  • Contact Us
  • Privacy Policy

What Will You Find

Automation is our area of writing where are included scripts, batch and various tips to automate your daily job.
Copyright © 2023 Get IT Solutions