|
5#

楼主 |
发表于 2008-1-4 18:32:17
|
只看该作者
原帖由 dgbgg 于 2008-1-4 01:49 PM 发表 
偶也想找。现在一般这么用:
dir xxx /b>aa.txt
%programfiles%\ue\uedit32.exe aa.txt
用ue的列块模式把aa.txt编辑成
ren aa.bbb AA.BBB的格式。
很笨哦!
写了一个简单的程序,不过不知道MoveFile函数为什么不能处理目录...
/*
将某个目录下所有的文件名统统转成大写
*/
#include <windows.h>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
void FilesInDir(string, vector<string> &);
int main(int argc, char **argv) {
if (argc != 2) {
cout << "Usage: " << argv[0] << " <dir>" << endl;
return -1;
}
vector<string> files;
FilesInDir(argv[1], files);
for (vector<string>::iterator i = files.begin(); i != files.end(); i++) {
string newname = *i;
transform(newname.begin(), newname.end(), newname.begin(), ::toupper);
// cout << *i << endl;
// cout << MoveFile((*i).c_str(), newname.c_str()) << endl;
MoveFile((*i).c_str(), newname.c_str());
}
return 0;
}
void FilesInDir(string dir, vector<string> &ret) {
WIN32_FIND_DATA wfd;
HANDLE fh;
BOOL b;
for (b = ((fh = FindFirstFile((dir + "\\*.*").c_str(), &wfd)) !=
INVALID_HANDLE_VALUE); b; b = FindNextFile(fh, &wfd)) {
if ((string(wfd.cFileName) != "..") && (string(wfd.cFileName) != ".")) {
ret.push_back(dir + "\\" + wfd.cFileName);
if (wfd.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY) {
FilesInDir(dir + "\\" + wfd.cFileName, ret);
}
}
}
return;
} |
|