diff --git a/tv_rename.cpp b/tv_rename.cpp index ee51077..dc1f5f1 100644 --- a/tv_rename.cpp +++ b/tv_rename.cpp @@ -163,10 +163,10 @@ void singleSeason( const std::string &path, const std::string &show, int season, return; for( const auto &x : files ) { std::string name = x.filename(); - std::string dir = std::regex_replace(x.c_str(), std::regex(name), ""); + std::string dir = x.parent_path(); unsigned long num; try { - num = std::stoi(std::regex_replace(name, std::regex(".*[sS][0-9]{0,2000}[eE]([0-9]{0,2000}).*"), "$1")); + num = std::stoi(std::regex_replace(name, std::regex(".*[sS][0]{0,2000}" + std::to_string(season) + "[eE]([0-9]{1,2000}).*"), "$1")); } catch (std::exception &e) { continue; } @@ -179,7 +179,7 @@ void singleSeason( const std::string &path, const std::string &show, int season, name = std::regex_replace(name, std::regex(">"), "is more than"); name = std::regex_replace(name, std::regex(":"), " -"); } - renamed_files.insert(dir + name); + renamed_files.insert(dir + "/" + name); renamed_episodes[num] = name; } }