Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TVPaint: Fix renaming of rendered files #3882

Merged
merged 2 commits into from
Sep 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions openpype/hosts/tvpaint/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,9 +646,6 @@ def rename_filepaths_by_frame_start(
filepaths_by_frame, range_start, range_end, new_frame_start
):
"""Change frames in filenames of finished images to new frame start."""
# Skip if source first frame is same as destination first frame
if range_start == new_frame_start:
return

# Calculate frame end
new_frame_end = range_end + (new_frame_start - range_start)
Expand All @@ -669,14 +666,17 @@ def rename_filepaths_by_frame_start(
source_range = range(range_start, range_end + 1)
output_range = range(new_frame_start, new_frame_end + 1)

# Skip if source first frame is same as destination first frame
new_dst_filepaths = {}
for src_frame, dst_frame in zip(source_range, output_range):
src_filepath = filepaths_by_frame[src_frame]
src_dirpath = os.path.dirname(src_filepath)
src_filepath = os.path.normpath(filepaths_by_frame[src_frame])
dirpath, src_filename = os.path.split(src_filepath)
dst_filename = filename_template.format(frame=dst_frame)
dst_filepath = os.path.join(src_dirpath, dst_filename)
dst_filepath = os.path.join(dirpath, dst_filename)

os.rename(src_filepath, dst_filepath)
if src_filename != dst_filename:
os.rename(src_filepath, dst_filepath)

new_dst_filepaths[dst_frame] = dst_filepath

return new_dst_filepaths