核心是 doc 中的 ren 命令
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
using namespace std;
string int2string(int n, int bit)
{
string s;
for(int i = 0; i < bit; i++)
s.push_back(n % 10 + '0'), n /= 10;
reverse(s.begin(), s.end());
return s;
}
void init(int &pos, int &len)
{
string s = "[HKG&X2][When_They_Cry][DVDRip][01][XviD_MP3][CRC32_1A58530A].sc.ass";
pos = s.find("01");
len = 2;
}
int main()
{
system("dir /b >file_directory.txt");
fstream in;
in.open("file_directory.txt");
int pos, len;
init(pos, len);
string s;
while(in >> s)
{
if(s == "rename.cpp") continue;
if(s == "rename.o") continue;
if(s == "rename.exe") continue;
if(s == "file_directory.txt") continue;
// 判断是否要转换
if(s.find("sc") == -1) continue;
// 进行转换
string op = "ren \"";
op += s + "\" " + s.substr(pos, len) + ".ass";
system(op.c_str());
}
in.close();
system("del file_directory.txt");
return 0;
}