/**
   * Rename Episode (PLUS all Episodes having the same MediaFile!!!).
   *
   * @param episode the Episode
   */
  public static void renameEpisode(TvShowEpisode episode) {
    // test for valid season/episode number
    if (episode.getSeason() < 0 || episode.getEpisode() < 0) {
      LOGGER.warn(
          "failed to rename episode "
              + episode.getTitle()
              + " (TV show "
              + episode.getTvShow().getTitle()
              + ") - invalid season/episode number");
      MessageManager.instance.pushMessage(
          new Message(
              MessageLevel.ERROR,
              episode.getTvShow().getTitle(),
              "tvshow.renamer.failedrename",
              new String[] {episode.getTitle()}));
      return;
    }

    LOGGER.info(
        "Renaming TvShow '" + episode.getTvShow().getTitle() + "' Episode " + episode.getEpisode());
    for (MediaFile mf : new ArrayList<MediaFile>(episode.getMediaFiles())) {
      renameMediaFile(mf, episode.getTvShow());
    }
  }
  public static String generateSeasonDir(String template, TvShowEpisode episode) {
    String seasonDir = template;

    // replace $1 and $2 as the only episode specific tokens
    seasonDir = seasonDir.replace("$1", String.valueOf(episode.getSeason()));
    seasonDir = seasonDir.replace("$2", lz(episode.getSeason()));
    seasonDir = seasonDir.replace("$1", String.valueOf(episode.getDvdSeason()));
    seasonDir = seasonDir.replace("$2", lz(episode.getDvdSeason()));

    // replace all other tokens
    seasonDir = createDestination(seasonDir, episode.getTvShow(), new ArrayList<TvShowEpisode>());

    // only allow empty season dir if the season is in the filename
    if (StringUtils.isBlank(seasonDir)
        && !(SETTINGS.getRenamerFilename().contains("$1")
            || SETTINGS.getRenamerFilename().contains("$2")
            || SETTINGS.getRenamerFilename().contains("$3")
            || SETTINGS.getRenamerFilename().contains("$4"))) {
      seasonDir = "Season " + String.valueOf(episode.getSeason());
    }
    return seasonDir;
  }