代码如下: int main() { for (int i = 1; i <= 7; i++) { for (int j = 1; j <= 38; j++){ if (j <= 9){ string path1 = "C:\\Users\\Zender\\Desktop\\object\\" + to_string(i) + "\\cam_0" + to_string(j) + ".png";//原图片所在路径 string path2 = "C:\\Users\\Zender\\Desktop\\object\\cam_0" + to_string(j) + "\\" + to_string(i) + ".png";//存储图片的新路径 cout << path1 << endl; if (rename(path1.c_str(), path2.c_str()) != 0) //nt rename(const char *oldname, const char *newname);