Created
August 30, 2019 02:10
-
-
Save plasma-effect/fd298b8c2e260b30741332d09b47892f to your computer and use it in GitHub Desktop.
指定したディレクトリ内のファイルのサフィックスにくっついた括弧を除去するやつ
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
#include<iostream> | |
#include<string> | |
#include<filesystem> | |
int main() | |
{ | |
std::string path; | |
std::getline(std::cin, path); | |
for (auto&& x : std::filesystem::recursive_directory_iterator(path)) | |
{ | |
std::cout << x.path() << std::endl; | |
if (!x.is_directory()) | |
{ | |
auto base = x.path().string(); | |
auto to = base; | |
auto end = std::prev(to.end()); | |
for (; end != to.begin() && *end != '.'; --end); | |
auto start = end; | |
for (; start != to.begin() && *start != '('; --start); | |
if (start != to.begin()) | |
{ | |
to.erase(std::prev(start), end); | |
std::filesystem::rename(base, to); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment