Link to home
Start Free TrialLog in
Avatar of thenightlife
thenightlifeFlag for United States of America

asked on

Renaming multiple folders in Windows 7

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.
Avatar of paul_mountcastle
paul_mountcastle
Flag of United States of America image

Looks like Metamorphose would work:
http://file-folder-ren.sourceforge.net/

I tested this on an XP machine with no issues.
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 ?
Avatar of florjan
florjan

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,

Florjan
Avatar of Anil
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


Use

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!


A>
If you did not reboot. Ctrl + Z
Avatar of thenightlife

ASKER

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?
Hi,

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,


A>

rename-dos.xls
ASKER CERTIFIED SOLUTION
Avatar of niaz
niaz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
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.