#include <io.h>
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
//读取文件夹设定
const string path = "D:\\pp\\";
int main(){
_finddata_t file;
long lf;
if((lf = _findfirst((path + "*.*").c_str(), &file))==-1)
cout<<"Not Found!"<<endl;
else{
// cout<<"file name list:"<<endl;
while(_findnext( lf, &file)==0){
{
string str=file.name;
//修改扩展名为.jpeg
str += ".jpeg";
//重命名文件
if (rename((path + string(file.name)).c_str(), (path + str).c_str()) == 0)
{
//cout << "1" << endl;
}
}
}
}
_findclose(lf);
return 0;
}
c++修改指定文件夹下所有文件扩展名
最新推荐文章于 2024-04-26 19:43:49 发布