diff --git a/source/net/filebot/cli/CmdlineOperations.java b/source/net/filebot/cli/CmdlineOperations.java index 1417b2a9..50230944 100644 --- a/source/net/filebot/cli/CmdlineOperations.java +++ b/source/net/filebot/cli/CmdlineOperations.java @@ -224,7 +224,7 @@ public class CmdlineOperations implements CmdlineInterface { episodes = applyEpisodeExpressionMapper(episodes, mapper); for (List filesPerType : mapByMediaExtension(filter(batch, VIDEO_FILES, SUBTITLE_FILES)).values()) { - matches.addAll(matchEpisodes(filesPerType, episodes, strict)); + matchEpisodes(filesPerType, episodes, strict).stream().map(this::unmap).forEach(matches::add); } } } @@ -254,6 +254,16 @@ public class CmdlineOperations implements CmdlineInterface { return renameAll(formatMatches(matches, format, outputDir), renameAction, conflictAction, matches, exec); } + private Match unmap(Match match) { + // add matches and unmap mapped episodes + if (match.getCandidate() instanceof MappedEpisode) { + MappedEpisode mapping = (MappedEpisode) match.getCandidate(); + log.fine(format("Reverse Map [%s] to [%s]", mapping.getMapping(), mapping.getOriginal())); + return new Match(match.getValue(), mapping.getOriginal()); + } + return match; + } + private List> matchEpisodes(Collection files, Collection episodes, boolean strict) throws Exception { // always use strict fail-fast matcher EpisodeMatcher matcher = new EpisodeMatcher(files, episodes, strict);