
检测文件夹的代码
#include <iostream>
#include <filesystem>
#include <regex>
namespace fs = std::filesystem;
bool isValidFolderName(const std::string& folderName) {
// 定义正则表达式,匹配要求的文件夹名称
std::regex pattern(R"(ZJ-S0\d{4}|arena|color|detect|duel)");
return std::regex_match(folderName, pattern);
}
void checkFolders(const fs::path& directory) {
for (const auto& entry : fs::recursive_directory_iterator(directory)) {
if (entry.is_directory()) {
std::string folderName = entry.path().filename().string();
if (!isValidFolderName(folderName)) {
std::cout << "不符合要求的文件夹路径: " << entry.path() << std::endl;
}
}
}
}
int main() {
fs::path directoryPath = "D:\\download\\20241027094554597"; // 替换为你的文件夹路径
checkFolders(directoryPath);
return 0;
}