Linux下 C++遍历目录下所有文件
1 rename(image_path.c_str(), image_path_new.c_str()); 2 remove(image_path_move.c_str());
上述批量操作的代码是在linux下的参数设置:
rename的参数,image_path为原文件的路径+文件名,image_path_new为文件重命名的路径+文件名。两者在windows下均为string类型即可,但是在linux下需要转换成char型。
remove的参数,image_path_move同样为删除文件的路径+文件名,不同系统下的参数格式也不同。