   c++ Recursive renaming of files/directories
  I am looking for a way in c++ to specify a directory, and then have it search through it, and all sub directories and rename the directories/files it finds. I found rename() in stdio.h but not sure how to search through each sub directory and file to rename them. Any help or code snippets would be appreciated :)   
  My implementation is win32 dependent and uses custom stuff (list , text processing)Here are the main classes that you can use in order to manipulate files and directories , path , etc.//--------------------------------------------------------------------------enum PathObjectFlags{is_directory= 1<<0,is_file= 1<<1,is_loaded= 1<<2,// if the object is dir , and all the subfolders and files are loaded};//--------------------------------------------------------------------------class Path;class PathObject: public ListNode<PathObject>{public://----------------------------PathObject();PathObject(char* Name, unsigned int Flags);PathObject(PathObject& other);voidoperator =(PathObject& other);~PathObject();//----------------------------char*getName()const;intisFile()const;voidtrimExt();boolhasCildren()const;unsigned intgetFlags()const;//----------------------------boolfind(Path &out,const char *Name,unsigned int withFlags = is_file);booldepthFind(Path &out,const char *Name,unsigned int withFlags = is_file);public:char*name;unsigned intflags;List<PathObject>subs;private:bool__find(Path & out , char *name,unsigned int Flags);// breadfirstprivate:friend class Path;};//--------------------------------------------------------------------------class Path{public:Path();Path(const char* name);Path(Path& other);voidoperator =(Path& other);//-------------------------------------------------------------------char*getPath() const;char*trim();// trim the last object from the pathvoidoperator +=(const char* path);boolisEmpty()const;voidclear();//-------------------------------------------------------------------voidls(List<PathObject>& output, bool files = true, bool dirs = true);voidscan(PathObject& rezult, bool files = true, bool dirs = true);voidmkdir(char* name, bool recursive = false);hddStreammkfile(const char* name, const char* mode = "wb");private:charlocation[MAX_PATH_LENGTH];unsigned intlength;};//--------------------------------------------------------------------------Basic usage:Path p("directory") or Path p("c:\\home");Path p(0); - curent path of the file starting with the drive.. eg: c:\blab la\...PathObject o; represents a file , or a folder;p.scan(o); - will search trough all the structure starting from path P;o- now holds the structure of folders and files; with it you can search inside for stuff, get exact location , etc;Ps: send a PM if you want the rest of the code , there is to much to post it here.The base code that can get all the files and folders from a folder is:Node: only one folder , this will not search inside other foldersWIN32_FIND_DATA fdata;HANDLEdhandle;{char buf[MAX_PATH_LENGTH];text::append(buf, "\\*", text::append(buf, location));if ((dhandle = FindFirstFile(buf, &fdata)) == INVALID_HANDLE_VALUE){return;// error}}while (true){if (FindNextFile(dhandle, &fdata)){if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY){//directoryif (dirs && !text::equal("..", fdata.cFileName))output.add(new PathObject(fdata.cFileName,is_directory));}else{// fileif (files)output.add(new PathObject(fdata.cFileName,is_file));}}else{if (GetLastError() != ERROR_NO_MORE_FILES){break;}else{FindClose(dhandle);return;// some sort of an error}}/**/}//if(FindClose(dhandle) == 0) //errorFindClose(dhandle);;  Boost version:#include <boost/filesystem.hpp>namespace fs = boost::filesystem;void recurse(const fs::path & p) {fs::directory_iterator di(p);fs::directory_iterator de;while (di != de) {try {if (fs::is_directory(di->status())) {recurse(di->path());// fs::rename(di->path(), ....);}if (fs::is_regular_file(di->status())) {// fs::rename(di->path(), ....);}} catch (const std::exception & e) {std::cout << e.what() << std::endl;}++di;}}int main(){recurse("r:/root");}Actual renaming and matching left as exercise.;  Why do you want to use C++ for this? It's an especially poor fit here.   ;  Because the games I do server modding for are done so with c++.Thanks for the examples :)   