|
|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
import re
|
|
|
|
|
import json
|
|
|
|
|
|
|
|
|
|
ONE_PIECE_SEASON_COUNT = [
|
|
|
|
|
8, # Season 1
|
|
|
|
|
@ -64,6 +65,7 @@ def _get_new_name(relative_episode_number, actual_season):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
backup_json = []
|
|
|
|
|
all_files = os.listdir(ONE_PIECE_DIR)
|
|
|
|
|
for f in all_files:
|
|
|
|
|
# skip files that have a season associated with them
|
|
|
|
|
@ -74,7 +76,14 @@ def main():
|
|
|
|
|
season = _get_episode_season(absolute_episode_number)
|
|
|
|
|
season_episode_number = _get_season_episode_number(season, absolute_episode_number)
|
|
|
|
|
new_name = _get_new_name(season_episode_number, season)
|
|
|
|
|
print(f"Renaming {f} to {new_name}")
|
|
|
|
|
backup_json.append({"old": f, "new": new_name})
|
|
|
|
|
|
|
|
|
|
# write a backup file in case we need to revert
|
|
|
|
|
with open("/home/cianhatton/rename-one-piece-backup.json", "w") as f:
|
|
|
|
|
json.dump(backup_json, f, indent=4)
|
|
|
|
|
|
|
|
|
|
for item in backup_json:
|
|
|
|
|
os.rename(f"{ONE_PIECE_DIR}/{item['old']}", f"{ONE_PIECE_DIR}/{item['new']}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
|