| | |
Hack Tool Development
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
Say you have a list of .wav files in a particular directory tree, and say you have another pile of .phr files that may or may not be in the same directory tree. The .phr files contain in text the names one or more .wav files. And you need to rename a bunch of the .wav files and have the associated change reflected in any relevant .phr file. How might you choose to set things up to do this "scripted" file renaming?
At present, I'm thinking that it might be done as follows:
Any suggestions?
At present, I'm thinking that it might be done as follows:
- Recurse the directory (tree) for .wav files and store the filenames in the first in a vector of pair of string.
- Modify the filename in a temp after the first and store as the second.
- Perform the renaming/copy-w-mod now or later.
- Recurse the directory (tree) for .phr files and store the filenames in a vector of string.
- Loop through the vector of .phr filenamse, open each, and search each line for an instance of the filename text.
- On match, replace text (via rewrite on-the-fly or whatever).
- Lather, rinse, repeat as necessary.
Any suggestions?
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
•
•
Join Date: Dec 2006
Posts: 1,089
Reputation:
Solved Threads: 164
bulk rename of all the .wav files in one go and updating the text in all the .phr files at another time can leave you in a messy state in the event of a crash (you would have to restart all over again after restoring from backups). you could consider renaming the .wav file and updating its text in the .phr file in one go.
perhaps, using a single map would be easier than having two different vectors. maybe something like this:
a. have a std::map<std::string,std::string> with the original/modified file names as the key and data.
b. recurse the directory (tree) for .wav files and insert the original/modified filenames in the map.
c. i. recurse the directory (tree) for .phr files, open each, and search each line for an instance of the filename text. ii. lookup the file name in the map, if found, rename the .wav file and replace filename text in the .phr file.
d. iterate through the map and rename any remaining .wav files. (which had no entries in the .phr files).
could be a lot easier to do it in python/perl/ruby instead of C++.
perhaps, using a single map would be easier than having two different vectors. maybe something like this:
a. have a std::map<std::string,std::string> with the original/modified file names as the key and data.
b. recurse the directory (tree) for .wav files and insert the original/modified filenames in the map.
c. i. recurse the directory (tree) for .phr files, open each, and search each line for an instance of the filename text. ii. lookup the file name in the map, if found, rename the .wav file and replace filename text in the .phr file.
d. iterate through the map and rename any remaining .wav files. (which had no entries in the .phr files).
could be a lot easier to do it in python/perl/ruby instead of C++.
![]() |
Similar Threads
- Possible hacking (Viruses, Spyware and other Nasties)
- need more clear distinction between turboc++&carbidec++ (C++)
Other Threads in the C++ Forum
- Previous Thread: c++ very basic, convert a string to an integer
- Next Thread: OpenGL? Graphics? Help please
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count data database delete deploy developer dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game getline givemetehcodez graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linker list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings struct temperature template text text-file tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






