Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Renaming multiple folders in Windows 7

Posted on 2011-02-14
Medium Priority
Last Modified: 2012-05-11
An accidental folder renaming operation added the number "2" to all folders in a specific directory.  Example: documents 2 or clients 2 etc.  There are thousands of these folders, and thus we are looking for a simple way to remove the number "2" from all folder names.  Suggestions?

Thank you.
Question by:thenightlife
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +3

Expert Comment

ID: 34889578
Looks like Metamorphose would work:

I tested this on an XP machine with no issues.

Expert Comment

ID: 34889645
It goes back in days when window was not available, I use to use a tool called xtree. That had the functionality to do rename using wildcard. I'm not sure is xtree  is still available.

How ever you can do it by either using excel to create a rename command for each folder or use a batch script (old  DOS command) to rename all the files.

Are all these folders are at same location or in multiple nested folder structure ?

Expert Comment

ID: 34889799
I recommend program called ReNamer. It's free for non commercial users. Here's the download link
http://www.den4b.com/?x=downloads. I use this program a lot and it's very useful. It doesn't need to be installed as it can be downloaded as an archive. To remove "2"'s you open ReNamer and click on add then a menu should open. After just click on Remove on left side of just opened menu. Then enter "2" you want removed or " 2" if you want spaces removed that you also don't want.Then just drag all files/folders to ReNamer. Click Preview and if satisfied with the result Rename.

Best Regards,

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.


Expert Comment

ID: 34889812
To rename one folder the syntax is    ren filename2.   filename.     in dos and like niaz suggested an excel file would be used to produce all the commands even if there are thousands it should work.

Assuming you got several levels of folders


dir *2 /b /a:d /s

To generate a list of all folders affected. Run the command at the root of the folder. Then use excel to generate commands like

ren c:\a\filename2.   c:\a\filename.
ren c:\a\filename2.   c:\a\filename.
ren c:\a\filename2.   c:\a\filename.
ren c:\b\filename2.   c:\b\filename.
ren c:\b\filename2.   c:\b\filename.

Export as a batch file and run it.

Please test on a couple of folders!


Expert Comment

ID: 34891026
If you did not reboot. Ctrl + Z

Author Comment

ID: 34892793
akajohn, I have all the folder names exported into an excel spreadsheet.  I did not have to do the sub-directories, so I removed the /s...thank goodness its only the root.  So, an example of one folder name that needs to be changed (on a mapped Y: drive)  Y:\Mus\View 2; I wish this name to be without the space and 2 (as well as the thousands of other folders).  Not sure how to approach it from your standpoint now?

Expert Comment

ID: 34893200

Attached spreadsheet:

Column B has examples of folders , all ending with a "2".

Column D is the command you need for renaming. After testing a few of those (copy paste it in a command line dos box in the folder Y:\MUS to test) copy the whole of column D in to a batch file and run it.
Fill down as many times as you need. You should paste the list of all affected folders in column B.

That should do the trick.
Hope this helps,



Accepted Solution

niaz earned 500 total points
ID: 34894172
Look at the following link for the details:


I have modified the above batch file to meet your need. It will rename all folders with '2' any where in their name (beginning, middle or end).

@echo off
setlocal enableextensions
for /D %%f in (*) do call :process "%%f"
goto :eof

pushd "%~dp1"

set fn=%~nx1
set fn=%fn:2=%

ren "%~nx1" "%fn%"

goto :eof  

Open in new window

Download the attached file in a test directory.
Rename the file from "rename_folders_2.txt" to "rename_folders_2.bat"

*** once you rename it to .bat on you system, do not double click it to open it. It will run the program. ****

Create bunch of folders with name containing 2 at the end as it is in your situation.
Run the "rename_folders_2.bat" file from a command prompt and it should work for win 7 as well.
I have tested it on XP.
Before you do any such changes it is always a good idea to make a BACKUP.

if you like you can change the "@ECHO OFF"  to "@ECHO ON"  and save the file as .bat (make sure your file type is all and NOT .TXT if using notepad.

at location where you want to test it you can run the command by typing

C:\TEST\rename_folder_2.bat > rename_folder_results.txt

This will generate a log file where you can see how it processed all the rename commands and if there is an error you will be able to see it.


Expert Comment

ID: 34898510
These are great solutions (some of which I may borrow and adapt to my environment), but it seems like a lot of work to go through in scripting this when Metamorphose  is freeware.

Author Comment

ID: 34902381
Thank you niaz!  The batch file worked flawlessly.  An incredible post that will indeed assist many.  Also a big thank you to akajohn...the excel thing worked but was a bit more tedious to complete.

Again thank you very much.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface Having the need * to contact many different companies with different infrastructures * do remote maintenance in their network required us to implement a more flexible routing solution. As RAS, PPTP, L2TP and VPN Client connections are no…
Have you ever had a hard drive that you can't boot into, but need to change the registry? Here is the solution! This article guides you through accessing and editing a registry of a non-primary drive. To read registry information on a non-prim…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question