您的位置:首页 > 编程语言 > C语言/C++

c++修改指定文件夹下所有文件扩展名

2017-01-13 15:16 183 查看
#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++
相关文章推荐