Created
July 25, 2018 08:51
-
-
Save samsonchen1989/ed47e67c4b275f72dd4307fb9ea6f96b to your computer and use it in GitHub Desktop.
批量重命名boost生成的vc141库为vc140
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // tool.cpp: 定义控制台应用程序的入口点。 | |
| // | |
| #include "stdafx.h" | |
| #include <iostream> | |
| #include <string> | |
| #include <io.h> | |
| #include <stdlib.h> | |
| #include <vector> | |
| #include <regex> | |
| using namespace std; | |
| string dirpath = "E:\\kcp_server\\boost_1_58_0\\VC14.0\\lib\\"; | |
| int main() | |
| { | |
| _finddata_t file; | |
| long lf; | |
| string subName = "*.dll";//要寻找的文件类型 | |
| vector<string> fileNameList; | |
| string fullName = dirpath + subName; | |
| //获取文件名向量 | |
| if ((lf = _findfirst(fullName.c_str(), &file)) == -1l) | |
| { | |
| cout << "Fail to find file!" << endl; | |
| } | |
| else | |
| { | |
| cout << ""; | |
| do { | |
| cout << file.name << endl; | |
| //str是用来保存文件名的字符串string | |
| string str(file.name); | |
| fileNameList.push_back(str); | |
| cout << endl; | |
| } while (_findnext(lf, &file) == 0); | |
| } | |
| _findclose(lf); | |
| //遍历文件名向量,并进行修改 | |
| string strReplace = "vc140"; | |
| for (vector<string>::iterator iter = fileNameList.begin(); iter != fileNameList.end(); ++iter) | |
| { | |
| string oldName = dirpath + *iter; | |
| //str1为原文件名要保留的部分 | |
| string newName = std::regex_replace(oldName, std::regex("vc141"), "vc140"); | |
| cout << "oldName:" << oldName << endl; | |
| cout << "newName" << newName << endl; | |
| rename(oldName.c_str(), newName.c_str()); | |
| } | |
| system("PAUSE"); | |
| return 0; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment