#include <iostream>
#include <string>
#include <io.h>
#include <sstream>
using namespace std;
bool RenameFileNames(string strPath, string newPath);
bool RenameFileNames(string oldPath,string newPath)
{
intptr_t hFile = -1;
struct _finddata_t fileinfo;
static int i = 1;
string path;
if ((hFile = _findfirst(path.assign(oldPath).append("\\*").c_str(),&fileinfo))!=-1)
{
do
{
// 如果當前是目錄,則continue
if (fileinfo.attrib & _A_SUBDIR)continue;
else // 對當前文件夾下的文件重命名
{
stringstream ss;
ss << i;
string new_name = path.assign(newPath).append("\\") + string(ss.str() + ".bmp");
rename(path.assign(oldPath).append("\\").append(fileinfo.name).c_str(), new_name.c_str());
i++;
printf("%s\n", new_name.c_str());
}
} while (_findnext(hFile,&fileinfo) == 0);
_findclose(hFile);
}
return true;
}