0
已解决
陈泽睿
高级光能
高级光能
#include <io.h>
#include <iostream>
#include <cstring>
#include <string>
#include <windows.h>
using namespace std;
string s,c;
_finddata_t file;
long lf;
int pos=0;
string t;
int main(){
cout<<" 文件后缀修改器2.0 \n";
cout<<"***********************************************\n";
cout<<"* 输入start开始修改,exit退出 *\n";
cout<<"***********************************************\n";
cout<<"请选择:";
cin>>t;
if(t.compare("start")!=0) exit(0);
cout<<"请先将文件存入文件夹中,并存入D盘!!!\n请输入要修改的扩展名(不带\".\"号):";
cin>>s;
s="."+s;
cout<<"请输入要修改的文件夹名称:";
getline(cin,c);
getline(cin,c);
string path="D:\\"+c+"\\";
if((lf = _findfirst((path + "*.*").c_str(), &file))==string::npos){
MessageBox(GetForegroundWindow(),"未查找到文件!!!","Error",MB_OK);
exit(0);
}else{
system("color 0c");
while(_findnext( lf, &file)==0){
string str=file.name;
for(int i=0;i<str.size();i++){
if(str[i]=='.'){
pos=i;
}
}
cout<<"修改:"<<str<<"为 ";
Sleep(50);
if(pos!=0) str.erase(pos,str.size()-pos);
str.append(s);
if(rename((path + string(file.name)).c_str(), (path + str).c_str()) == 0){
cout<<str<<endl;
}
}
}
_findclose(lf);
Sleep(500);
system("color 0A");
cout<<"修改完成!!! \n";
system("pause");
cout<<"谢谢使用!!!";
return 0;
}
0
0
0
0
0
0
0
0
0