Find place for simple remap script #264

Closed
opened 2024-03-15 17:32:49 +01:00 by Nick Alberelli · 0 comments
Member
import bpy
from pathlib import Path


def get_new_filepath(filepath):
    editorial_str = "//../../../../../render/heist/editorial/"
    if editorial_str in filepath:
        if not Path(filepath).exists():
            return
        return filepath.replace(editorial_str, '//')
    
    shot_preview_str = '//../../../../../render/heist/shot_previews/'
    if shot_preview_str in filepath:
        if not Path(filepath).exists():
            return
        return filepath.replace(shot_preview_str, '//') 


def main():
    for strip in bpy.context.scene.sequence_editor.sequences_all:
        if strip.type == "IMAGE":
            new_path = get_new_filepath(strip.directory)
            if not new_path:
                print("Failed to Remap", strip.name)
                continue
            strip.directory = new_path
            print("Remapped", strip.name, "to", strip.directory)

        if strip.type == "MOVIE":
            new_path = get_new_filepath(strip.filepath)
            if not new_path:
                print("Failed to Remap", strip.name)
                continue
            strip.filepath = new_path
            print("Remapped", strip.name, "to", strip.filepath)
            
        if strip.type == "SOUND":
            new_path = get_new_filepath(strip.sound.filepath)
            if not new_path:
                print("Failed to Remap", strip.name)
                continue
            strip.sound.filepath = new_path
            print("Remapped", strip.name, "to", strip.sound.filepath)

    for strip in bpy.context.scene.sequence_editor.sequences_all:
        if strip.type == "IMAGE":
           if "render" in strip.directory:
                print("ERROR!", strip.name)

        if strip.type == "MOVIE":
            if "render" in strip.filepath:
                print("ERROR!", strip.name)
                
        if strip.type == "SOUND":
            if "render" in strip.sound.filepath:
                print("ERROR!", strip.name)
main()
print("Filepath Update Complete")
```python import bpy from pathlib import Path def get_new_filepath(filepath): editorial_str = "//../../../../../render/heist/editorial/" if editorial_str in filepath: if not Path(filepath).exists(): return return filepath.replace(editorial_str, '//') shot_preview_str = '//../../../../../render/heist/shot_previews/' if shot_preview_str in filepath: if not Path(filepath).exists(): return return filepath.replace(shot_preview_str, '//') def main(): for strip in bpy.context.scene.sequence_editor.sequences_all: if strip.type == "IMAGE": new_path = get_new_filepath(strip.directory) if not new_path: print("Failed to Remap", strip.name) continue strip.directory = new_path print("Remapped", strip.name, "to", strip.directory) if strip.type == "MOVIE": new_path = get_new_filepath(strip.filepath) if not new_path: print("Failed to Remap", strip.name) continue strip.filepath = new_path print("Remapped", strip.name, "to", strip.filepath) if strip.type == "SOUND": new_path = get_new_filepath(strip.sound.filepath) if not new_path: print("Failed to Remap", strip.name) continue strip.sound.filepath = new_path print("Remapped", strip.name, "to", strip.sound.filepath) for strip in bpy.context.scene.sequence_editor.sequences_all: if strip.type == "IMAGE": if "render" in strip.directory: print("ERROR!", strip.name) if strip.type == "MOVIE": if "render" in strip.filepath: print("ERROR!", strip.name) if strip.type == "SOUND": if "render" in strip.sound.filepath: print("ERROR!", strip.name) main() print("Filepath Update Complete") ```
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: studio/blender-studio-tools#264
No description provided.