Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using std::cin;
- using std::cout;
- using std::endl;
- #include <fstream>
- using std::ifstream;
- using std::ofstream;
- #include <map>
- using std::map;
- #include <array>
- using std::array;
- #include <filesystem>
- using std::experimental::filesystem::path;
- using std::experimental::filesystem::recursive_directory_iterator;
- using std::experimental::filesystem::create_directories;
- using std::experimental::filesystem::exists;
- using std::experimental::filesystem::copy;
- using std::experimental::filesystem::remove;
- #include <string>
- using std::string;
- using std::getline;
- const array<char, 9> PROHIBITED_CHARACTERS
- {
- '\\', '/', ':', '*', '?', '"', '<', '>', '|'
- };
- int main()
- {
- map<string, string> gameList;
- ifstream knownGamesIn;
- knownGamesIn.open("GameIDs.txt");
- if (knownGamesIn.is_open())
- {
- string currentLine, gameID, gameName;
- int tabPos;
- while (getline(knownGamesIn, currentLine))
- {
- tabPos = currentLine.find('\t');
- gameID = currentLine.substr(0, tabPos);
- gameName = currentLine.substr(tabPos + 1);
- gameList[gameID] = gameName;
- }
- knownGamesIn.close();
- }
- ofstream knownGamesOut;
- string switchAlbumPath = "no swatch";
- for (char drive = 'A'; drive <= 'Z' && switchAlbumPath == "no swatch"; drive++)
- {
- string tmp(1, drive);
- tmp += ":\\Nintendo\\Album";
- if (exists(tmp)) switchAlbumPath = tmp;
- }
- int totalFiles = 0;
- int currentFile = 1;
- path current;
- cout << "Getting total number of files..." << endl;
- for (auto& p : recursive_directory_iterator(switchAlbumPath)) // iterate through all to get total files for progress
- {
- current = p;
- string fileName = current.filename().generic_string();
- if (fileName.size() == 53) totalFiles++;
- }
- for (auto& p : recursive_directory_iterator(switchAlbumPath))
- {
- current = p;
- string fileName = current.filename().generic_string();
- if (fileName.size() == 53) // AAAAAAAAAAAAAAAA-BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB.jpg (or .mp4)
- {
- string format = fileName.substr(fileName.size() - 4);
- string dateInfo = fileName.substr(0, 16);
- string gameID = fileName.substr(17, 32);
- string gameName;
- if (gameList.count(gameID) == 0) // If game ID isn't in list
- {
- cout << "Enter game name for current ID (" << gameID << "): ";
- getline(cin, gameName);
- gameList[gameID] = gameName;
- string line = gameID + ' ' + gameName + '\n';
- knownGamesOut.open("GameIDs.txt", std::ios::app);
- knownGamesOut << line;
- knownGamesOut.close();
- }
- else gameName = gameList[gameID];
- string dir = "C:\\Test\\" + gameName;
- for (int i = 0; i < dir.size(); i++) for (int ch = 0; ch < PROHIBITED_CHARACTERS.size(); ch++) if (dir[i] == ch) dir[i] = '_';
- string file = dir + "\\" + dateInfo + format;
- for (int i = 0; i < file.size(); i++) for (int ch = 0; ch < PROHIBITED_CHARACTERS.size(); ch++) if (file[i] == ch) file[i] = '_';
- if (!exists(dir)) create_directories(dir);
- if (!exists(file))
- {
- copy(p, file);
- cout << "Copied ";
- }
- else cout << "Already copied ";
- cout << currentFile << "/" << totalFiles << endl;
- currentFile++;
- }
- }
- system("Pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement