Thread: File Renamer
View Single Post
Old Sep 3rd, 2004, 5:49 PM   #4
kurifu
Expert Programmer
 
kurifu's Avatar
 
Join Date: Jul 2004
Location: Halifax, Nova Scotia (Canada)
Posts: 784
Rep Power: 5 kurifu is on a distinguished road
Send a message via ICQ to kurifu Send a message via MSN to kurifu
You know a map would be a really good container to use to accomplish that function. If you store the names of the file within a file and change the names there first, you are not going to know the original file names to change. You will need to maintain a file which keeps the file name maps.

Ultimately you could just use a map class in C++ and maintain the map of all files, store the full directory of the file (relative to your listing point) to prevent map collisions, and the map value will be the name you want to change the file to.

Iterate through your map and make the changes you want, popping values off your map (or erasing them since I do not think you can pop from a map) as you rename each of your files. Store results into a file or on the stdout if you want.

Using IR's rename code is probably the most robust means, if you do not need robust remember you can always use system( "mv orginal_filename new_filename" )--if you do that remember to use full diretories in your map key and value.
__________________
Clifford Matthew Roche <geek@cliffordroche.com>
Web Hosting: http://www.crd-hosting.com
Consulting: http://www.crdev-consulting.com
kurifu is offline   Reply With Quote