Today I'm struggling on a problem that was already half answered on other posts.
Here is what I try to do in c++ using dos command through the system command:
command = "s: && cd " + all_paths[i] + " && rename \"" + linestring + "\" \"" + completeCorrectName+"\"";
//what it really contain is => "s: && cd S:\\Holliday\\Spain\\ && rename \"Spain - été 2018 !.mkv\" \"Spain - pool 2018.mkv\""
system(command.c_str());
This is a dos command that I launch through a c++ program so I can use a lot more native functions.
Everything is working fine ! Except that I cannot rename a file that is containing special characters. Because of that, I get an error: "Specified file unreachable". And that is because special characters are memorized in my string variable as this:
"maŒtre et ‚lŠve.mkv"
So I tried "wstring"
, I tried "#Define UNICODE"
and also "#Define _UNICODE"
... Nothing works.
EDIT: I used cmd/dos because of the dir method which is usefull. I save the dir method like this:
command = "s: && cd " + all_paths[i] + " && dir /a-d /o-d /b *";
FILE* fpipe = _popen(command.c_str(),"r"); // run dir command and save it inside fpipe => memory file
if (fpipe) // If we can read it successfully
{
char line[500];
string linestring;
while (fgets(line, 500, fpipe)) // looping on each line
{
linestring.clear();
for (int j : line) //Convert buffer in string
{
linestring.push_back(j);
}
}