software / command to batch rename files

Associate
Joined
20 May 2004
Posts
138
I'm wanting to rename every file within a folder to include the name of the folder they are in. For instance, if the file is called 'abc' in the 'z' folder it will rename it 'abc z'.

I'm looking to do this for several hundred files within 8 folders.

Anybody know of a MS dos command that may do it in batches? Or is there a piece of software that does this?
 
This is very rough and ready, basically a nested loop parsing through all the directories and all the files in them. Put the line below in a batch file and run it from the path above the folders containing the files.

Code:
for /d %dirname in (*.*) do for /f %filename in (%dirname%\*.*) do ren %filename% "%filename% %dirname%"

Whatever you do, backup the files as they stand before you try this!
 
Back
Top Bottom