From cdf512023403561ad7be456d899ea20f73fea689 Mon Sep 17 00:00:00 2001 From: zvon Date: Sun, 23 Sep 2018 12:04:34 +0200 Subject: [PATCH] Fixed random regex mishaps --- tv_rename.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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; } }