Tuesday, February 21, 2012

Rename all Files in Folders with Sub-Folders

I recently wanted to update version numbers on a ton of AutoCAD Blocks. I copied the old blocks in their current folder structure to a new location and needed to add a version number to the end of each DWG file. This folder structure treed out like a Mighty Oak and the idea of manually changing every file made me nauseous.


You can go old school and open up a DOS prompt by typing CMD in the search box in the start menu. To change every file in a folder quick by browsing to the folder in question and type out...


REN *.dwg *_V2.dwg


I gues you should some DOS commands like CD to change directories. To find out more, just type HELP in the DOS window. DOS will supply a whole list of helpful commands and what they do. Once you figure that part out, the command above works fine,one folder at a time.


To handle a folder structure like I had you'll need a DOS statement with more horse power. This baby below does the trick. Just go to the top folder in your structure and let her rip! It takes about two seconds to rename hundreds of files.


for /f "tokens=* delims= " %a in ('dir /b /ad /s') do rename "%a\*.dwg" "*_V2.dwg"


If you are a copy/paste type of person, you might be annoyed to find the DOS command prompt doesn't seem to want to copy or paste. Click the little icon at the left of the title bar, then click Edit, then Paste. To copy, do the same except pick Mark then highlight want you want to copy out of the DOS editor.


What do you know, that old school DOS really is good for something.

10 comments:

The CAD Setter Out said...

OK, I didn't already write a post on this one... you're safe ;)

However, I wanted to recommend a programme called 'Renamer' that really helps with re naming files (but not folders!).

Check out ReNamer

And thanks again to Melanie Stone for recommending it!

plawton said...

Sir:

We are in the process of converting all of our CAD details to Revit. We find that in our CAD details we have many examples of wide polylines, along with donuts.

Do you know of a LISP or ARX routine that will convert wide polylines and donuts to polygons, retaining the width information (that you would see if set FILLMODE tto 0)?

Thanks

Todd M Shackelford said...

I don't think it will be easy.

Check out this thread if that helps.

http://forums.augi.com/showthread.php?t=105441

Tess said...

Wow... thanks so much! You've saved me hours of renaming work for an intricate folder structure.

Gotta love DOS!

ravi kumar bulusu said...

awesome...it saved lot of my time. thanks for sharing this command.

Unknown said...

Hi Todd,

I saw this posting on Renaming all Files in Folders with Sub-Folders
and I was wondering how could I make it work to accept a user input...
My problem is that everyday I have to change the date of all the files contained in a folder in all its subfolders for example from *03112013*.* to *03122013*.*
My problem is not the extension but the name of the file
I would appreciate a little bit of your advice on this

Thanks

Carlos

Unknown said...

Hi Todd

I saw your posting on Renaming all Files in Folders with Sub-Folders and I was wondering how can I make it work to change the name of a file using user inputs. My problem is that everyday I have to roll a folder of files and renaming them from yesterday date to current date

So I was thinking in something like this:

@echo off
set /p UserLBD=Please type the month and day of the previous working date:
set oldate=%UserLBD%
set /p UserNBD=Please type the month and day of the next working date:
set newdate=%UserNBD%
for /f "tokens=* delims= " %a in ('dir /b /ad /s') do rename "%a\*%oldate%*.*" "*%newdate%*.*"

But it doesn't work

I would appreciate a little bit of your advice on this one. At least if you know of a freeware I can use to rename files

Thanks

Carlos

Anonymous said...

Awesome! I had a hundred folders with a several files each to rename... one line in the command prompt and done!

Anonymous said...

for /f "tokens=* delims= " %a in ('dir /b /ad /s') do rename "%a\*.dwg" "*_V2.dwg"

Thanks! As an old 'dos hacker' I didn't understand much of this command except the ren part, but it worked like a charm and will save me hours of work.
Bob

Unknown said...

Yea but i need to rename a folder that i dont know the name of but i know the folder its in. Can you help me.