/ Published in: C++
URL: http://www.wikihow.com/Rename-Files-in-QT
for more info see the link
Expand |
Embed | Plain Text
/** * Prakash Manandhar, http://p-manandhar.info * Rename all *4.a files in a directory to add a d before the 4. */ #include <QtCore> #include <QtGui> int main (int argc, char ** argv) { char * path; if (argc == 1) path = "."; else path = argv[1]; QDir dir (path); QStringList filters ("*4.a"); QFileInfoList list = dir.entryInfoList (filters); for (int i = 0; i < list.size(); ++i) { QFileInfo fInfo = list.at(i); QString fPath = fInfo.absoluteFilePath(); qDebug() << fPath; QFile file (fPath); QString fPath_ren = fPath; fPath_ren.chop(3); fPath_ren += "d4.a"; dir.rename(fPath, fPath_ren); } return 0; }
You need to login to post a comment.
