I am new to Qt and learning about renaming files with the QDir and QFile libraries.
I know how to rename and I can do it but when I try in this loop it does not work.
QDir editFile;
std::cout << "Attempting to chop and put .mp4 onto a regular file.\n";
QString fileNameBuf{argv};
QString fileOriginal{argv};
for(int l{0}; l < fileNameBuf.size(); ++l)
{
if(fileNameBuf.at(l) == '.')
{
fileNameBuf.chop(fileNameBuf.size() - l);
break;
}
}
fileNameBuf.append(".mp4");
if(editFile.rename(argv, fileNameBuf))
std::cout << "Successful\n";
else
std::cout << "did not make it.\n";
This is actually in a function that sends a QString named argv. argv is a file path. I have it append .mp4 and remove the old extension. I have heard and know that if you do Q rename wrong it will not work. Please help me with this code. I have looked at other posts about this but they do not seem to help.