Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <boost/filesystem.hpp>
- #include <string>
- #include <iostream>
- #include <sstream>
- using namespace boost::filesystem;
- //****************************************************************************************
- int main()
- {
- bool recurse = true;
- // C:\Users\admin\Desktop\testgo
- path pathDest = "C:\\Users\\admin\\Desktop\\testgo";
- int a = 1;
- // using namespace boost::filesystem;
- recursive_directory_iterator it("C:\\Users\\admin\\Desktop\\test"), end;
- for (; it != end; ++it)
- {
- if (!recurse)
- {
- it.no_push(); // disable recurse
- } // end if
- if (!is_regular_file(*it))
- {
- continue;
- } // end if
- // make the validity check
- auto filepath = it->path();
- // check if the fileextension is .bmp
- try
- {
- if(filepath.extension() == ".bmp")
- {
- // rename(const path& old_p, const path& new_p);
- std::ostringstream os;
- os << a <<".bmp";
- //copy_file(filepath, pathDest);
- //dont need this since copy file can also rename it //rename(pathDest, pathDest/os.str());
- copy_file(filepath, pathDest/os.str());
- a++;
- } // end if
- }// end try
- catch(const std::exception& e )
- {
- std::cout<< "abc: "<< e.what() << "\n" ;
- }
- } // end for
- }
Add Comment
Please, Sign In to add comment