Move File Functions
On same drive
string source_path;
string dest_path;
source_path = "/home/pi/file_oldname";
dest_path = "/home/pi/file_newname";
rename(source_path.c_str(), dest_path.c_str());
To an external drive
Moving between file systems is not possible with rename()
string source_path;
string dest_path;
source_path = "/home/pi/file_oldname";
dest_path = "/home/pi/file_newname";
ifstream ifstream1(source_path.c_str(), ios::in | ios::binary);
ofstream ofstream1(dest_path.c_str(), ios::out | ios::binary);
ofstream1 << ifstream1.rdbuf();
remove(source_path.c_str());
Move Multiple Files Using A Command
#define DB_FILEIO_DIRECTORY_1 "/home/pi/myfolder1"
#define DB_FILEIO_DIRECTORY_2 "/home/pi/myfolder2"
string CommandString;
//Example command: "mv /path/sourcefolder/* /path/destinationfolder/"
CommandString = "mv ";
CommandString += DB_FILEIO_DIRECTORY_1;
CommandString += "/*.txt "; //Use this for all files: "/* "
CommandString += DB_FILEIO_DIRECTORY_2;
CommandString += "/";
system(CommandString.c_str());
