baked-archive-cleanup-script
Script that can be run in Nuke Script Editor (or Cragl smartScripter)
Repo: https://github.com/BakedStudios/baked-archive-cleanup-script
This Python script provides an interactive Nuke panel and command-line utilities to identify and delete EXR render files according to configured rules.
Overview
Written with python QT framework to include:
- GUI
- Loading Bar
- Feedback in GUI
The program:
-
Scans published render folders within a Nuke script context.
-
Identifies EXR sequences to delete based on ShotGrid version status:
- All renders linked to versions with status na.
- Older renders for versions with status bkdn, except the newest version.
- Older renders for versions with status note, except the two newest versions.
-
Offers a dry-run mode to preview deletions without removing files.
Key Components
RenderCleanup Class
-
Attributes:
deleted_frames: List of file paths that would be or have been deleted.frames_to_delete: List of candidate file paths scheduled for deletion.dry_run: Boolean flag toggling preview-only mode.
-
Methods:
scan_renders(): Walks render directories and populatesframes_to_delete.filter_by_status(): Queries ShotGrid viasgAPI to group renders by version status and prunes based on retention rules.perform_deletion(): Deletes folders or files inframes_to_delete(or no-op in dry-run).setup_ui(): Builds the Nuke panel with buttons, checkboxes, and progress indicator.on_scan_clicked(): Handler to run scan and update UI with results.on_delete_clicked(): Handler to execute deletions and log outcomes.
Usage
-
Within Nuke:
- Launch the Render Cleanup panel from the menu.
- Toggle Dry Run to preview.
- Click Scan to list candidates.
- Click Delete to remove selected renders.
-
CLI Mode:
python render_cleanup.py --project_id 1234 --dry-run
Command-Line Entrypoint
- Supports running outside Nuke for batch cleanup:
python render_cleanup.py --project_path /path/to/project \
[--dry-run] [--log-file cleanup.log]--dry-run: Report files without deleting.--log-file: Path to write deletion log.
Logging & Errors
- Utilizes Python
loggingfor informative messages. - Captures and prints stack traces on unexpected exceptions.
- UI shows error dialogs for failures during scan or delete.
Dependencies
- Nuke Python API (
nukemodule) - ShotGrid Python API (
shotgun_api3) - Standard libraries:
os,sys,shutil,traceback,collections,logging