恭喜ZJ-S00247同学
  • 板块灌水区
  • 楼主csxx601cjy
  • 当前回复18
  • 已保存回复18
  • 发布时间2024/10/27 22:16
  • 上次更新2024/10/28 12:02:28
查看原帖
恭喜ZJ-S00247同学
1283951
csxx601cjy楼主2024/10/27 22:16

检测文件夹的代码

#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;
}

2024/10/27 22:16
加载中...