diff --git a/tv_rename.cpp b/tv_rename.cpp index e035ad5..cc3c4f0 100644 --- a/tv_rename.cpp +++ b/tv_rename.cpp @@ -90,12 +90,20 @@ std::vector>> getRena auto pos = og_name.find_last_of('.'); // get desired filename auto name = compilePattern(pattern, season, num+1, og_name.substr(0, pos), episodes[num], show) + og_name.substr(pos); + // replace '/' with '|' + for( size_t i = 0; i < name.size(); i++ ) { + if( name[i] == '/' ) { + name[i] = '|'; + } + } // replace characters illegal in windows if desired if( !linux ) { - name.erase(std::remove_if(name.begin(), name.end(), [](char x) {return x == '?' || x == '"' || x == '\\' || x == '|' || x == '*';}), name.end()); + name.erase(std::remove_if(name.begin(), name.end(), [](char x) {return x == '?' || x == '"' || x == '\\' || x == '*';}), name.end()); size_t max{name.size()}; for( size_t i = 0; i < max ; i++ ) { - if( name[i] == '<' ) { + if( name[i] == '|' ) { + name[i] = '-'; + }else if( name[i] == '<' ) { name[i] = 'i'; name.insert(i+1, "s less than"); max += 11; @@ -109,6 +117,13 @@ std::vector>> getRena max++; } } + for( size_t i = 0; i < max; i++ ) { + if ( name[i] == ' ' && name[i+1] == ' ' ) { + name.erase(i, 1); + max--; + i--; + } + } } renamed_files.emplace_back(dir, std::pair(og_name, name)); }