Created
July 25, 2019 16:55
-
-
Save MasterGroosha/2f3d47cd995e681038229b459f4bfb4a to your computer and use it in GitHub Desktop.
This file contains 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 <experimental/filesystem> | |
#include <iostream> | |
#include <string> | |
#include <sstream> | |
#include <iomanip> | |
using namespace std; | |
namespace fs = std::experimental::filesystem; | |
int main(int argc, char** argv) | |
{ | |
if (argc < 2) | |
{ | |
cout << "Please enter path!\n"; | |
exit(EXIT_FAILURE); | |
} | |
const string dirPath = argv[1]; | |
auto dirIterator = fs::directory_iterator(dirPath); | |
for (auto &file : dirIterator) | |
{ | |
auto old_name = file.path().filename().string(); | |
stringstream ss; | |
ss << std::setfill('0') << std::setw(12 + 5) << old_name; | |
auto new_name = ss.str(); | |
fs::rename(dirPath + old_name, dirPath + new_name); | |
cout << "Renamed " << old_name << " to " << new_name << endl; | |
} | |
return 0; | |
} |
stek29
commented
Jul 26, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment