Skip to content

Commit

Permalink
Merge pull request #191 from Heavybullets8/master
Browse files Browse the repository at this point in the history
  • Loading branch information
Drazzilb08 authored Oct 4, 2024
2 parents 291174c + 76f927c commit 5a0724b
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions modules/poster_renamerr.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,18 +313,26 @@ def rename_files(matched_assets, script_config, logger):
new_file_path = os.path.join(dest_dir, new_file_name)

# Check if the new file path already exists
if os.path.isfile(new_file_path):
if os.path.lexists(new_file_path):
existing_file = os.path.join(dest_dir, new_file_name)
# Check if the existing file is the same as the new file True = same, False = different
if not filecmp.cmp(file, existing_file):
if file_name != new_file_name:
messages.append(f"{file_name} -renamed-> {new_file_name}")
discord_messages.append(f"{new_file_name}")
else:
if not print_only_renames:
messages.append(f"{file_name} -not-renamed-> {new_file_name}")
try:
# Check if the existing file is the same as the new file True = same, False = different
if not filecmp.cmp(file, existing_file):
if file_name != new_file_name:
messages.append(f"{file_name} -renamed-> {new_file_name}")
discord_messages.append(f"{new_file_name}")
else:
if not print_only_renames:
messages.append(f"{file_name} -not-renamed-> {new_file_name}")
discord_messages.append(f"{new_file_name}")
if not dry_run:
if action_type in ["hardlink", "symlink"]:
os.remove(new_file_path)
process_file(file, new_file_path, action_type, logger)
except FileNotFoundError:
# Handle the case where existing_file is a broken symlink
if not dry_run:
os.remove(new_file_path)
process_file(file, new_file_path, action_type, logger)
else:
if file_name != new_file_name:
Expand Down

0 comments on commit 5a0724b

Please sign in to comment.