rendered paste body#include <stdio.h>
#include <sstream>
#include <vector>
#include <string>
#include <iostream>
#include <fstream>
using namespace std;
string iPut;
/********************************************************************************/
vector<string> split(const string& str, const string& delimiters)
{
vector<string> tokens;
string::size_type lastpos = str.find_first_not_of(delimiters, 0);
string::size_type pos = str.find_first_of(delimiters, lastpos);
while (string::npos != pos || string::npos != lastpos)
{
tokens.push_back(str.substr(lastpos, pos - lastpos));
lastpos = str.find_first_not_of(delimiters, pos);
pos = str.find_first_of(delimiters, lastpos);
}
return tokens;
}
/********************************************************************************/
int main(int argc,char **argv)
{
ifstream inFile;
int i=0;
if(argc!=5) { cout << "** Error\n" << argv[0] << " robocopy.exe <file> \"\\\\nassy1\" \"\\\\nas02\"\n";fflush(stdout); exit(0); }
inFile.open(argv[2]);
if(!inFile)
{
cout << "Issue Opening " << argv[2] << "\n";
exit(0);
}
while(getline(inFile,iPut))
{
stringstream oPut;
string Path;
oPut<<argv[3];
Path=iPut;
vector<string> result=split(Path,"\\");
Path.clear();
for(i=0;i<(int)result.size()-1;i++)
{
Path+="\\";
Path+=result[i];
}
oPut.str("");
oPut.clear();
oPut << argv[1] << " \"" << argv[3] << Path << "\" \"" << argv[4] << Path<< "\" \"" << result[(int )result.size()-1] <<"\"";
string cmd=oPut.str();
cout << cmd << "\n";
system(cmd.c_str());
iPut="";
}
inFile.close();
}