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.
Post a Comment