Renamer-fork

:placard: Summary Renames scene files based on scene details while cleaning emoji and unicode.
:link: Repository https://github.com/inphobia/renamer-fork
:information_source: Source URL -
:open_book: Install How to install a plugin?

about renamer-fork

this is a fork of renamer-dev by GitHub - Serechops/Serechops-Stash: For all things Stash related. · GitHub

differences

features gained

  • strips even more punctuation marks by default
  • removes all emoji from filename
  • runs the string through unidecode so it’s mostly ascii
  • also gets rid of zero width unicode chars and other such nonsense
  • also fetches a scene’s studio code to be used as a key
  • limits the maximum length per key

features lost

  • adding tags to renamed files
  • support for studio_templates (code is still there using old codepath)

features wishlist

  • take favorites into account when sorting keys with multiple options, like tags or performer
  • invoke rename from ui instead scene.update.post()

Using renamer-fork

[!note]
All changes are made when a Scene is updated and saved. Start small, make sure you get the changes you want in place first, then Rename away!

[!note]
renamer-fork does not write to sqlite. when a file is renamed you’ll need run a new scan so stash can update it’s data

When you have installed the renamer-fork plugin, hop into your plugins directory, renamer-fork folder > open renamer_settings.py with your favorite code/text editor and you’ll see this:

# Importing config dictionary
# renamer_settings.py
config = {
    "api_key": "",  # Your API key, if needed for the GraphQL endpoint
    "endpoint": "http://localhost:9999/graphql",  # GraphQL endpoint
    "log_path": "./renamer.log",  # Path to log file
    "default_move_path": r"C:\No Studio",  # Default path for moving files
    "wrapper_styles": {
        "studio": ('', ''),
        "title": ('', ''),
        "performers": ('', ''),
        "date": ('', ''),
        "height": ('[', ']'),
        "video_codec": ('[', ']'),
        "frame_rate": ('[', ']'),
        "tag": ('[', ']'),
        "stash_id": ('[', ']'),
        "code": ('[', ']'),
    },
    "separator": '_',  # Separator used in filenames
    "key_order": [
        "date",
        "performers",
        "title",
        "code",
        "video_codec"
    ],
    "exclude_keys": ["height", "frame_rate"],  # Keys to exclude from filename formation
    "move_files": True,  # Enable moving of files
    "rename_files": True,  # Enable renaming of files
    "dry_run": True,  # Dry run mode
    "max_tag_keys": 5,  # Maximum number of tag keys in filename
    "tag_whitelist": [],  # List of tags to include in filename
    "exclude_paths": [],  # Paths to exclude from processing
    "stashbox_endpoints": ["https://stashdb.org/graphql"],
    "tag_specific_paths": {
        "Movie": r"E:\Movies"  # Specific paths based on tags
    },
    "regex_transformations": {
        "all_uppercase": {  # Transforms text to uppercase
            "fields": ["performers"],  # Specify fields to transform
            "pattern": ".*",  # Match any text
            "replacement": lambda match: match.group().upper()  # Transform to uppercase
        },
        "all_lowercase": {  # Transforms text to lowercase
            "fields": ["title"],  # Specify fields to transform
            "pattern": ".*",  # Match any text
            "replacement": lambda match: match.group().lower()  # Transform to lowercase
        }
    },
    "associated_files": ["srt", "vtt", "jpg", "png", "webp"],  # File extensions of associated files to rename
    "performer_sort": "name",  # Sort performers by name
    "performer_limit": 2,  # Limit number of performers listed in filename
    "date_format": "%Y-%m-%d",  # Date format in filenames
    "studio_templates": {
        "1By-Day": "$studio - $date - $performers - $title"
    }
}

Renamer Settings File

This settings file (renamer_settings.py) controls the behavior of the Renamer script. Follow the instructions below to properly modify the settings file according to your preferences.

Configuration Options

Config Dictionary

The config dictionary contains various settings that influence how the Renamer script operates. Here are the available configuration options:

  • wrapper_styles: Wrapper style defines what brackets, if any, to use around each key value. Where available brackets are ‘{}’, ‘’, ‘()’, or ‘’ for none.
  • separator: Define the separator to use between different parts of the filename.
  • key_order: Define the order of keys in the filename.
  • exclude_keys: Specify keys to exclude from the formed filename.
  • move_files: Define whether files should be moved when renaming.
  • rename_files: Define whether files should be renamed when moved.
  • dry_run: Define whether the script should run in dry run mode.
  • max_tag_keys: Define the maximum number of tag keys to include in the filename.
  • tag_whitelist: Define a whitelist of allowed tags.
  • exclude_paths: Define paths to exclude from modifications.
  • tag_specific_paths: Define a tag specific path to move a scene based on specific tags it contains.

Wrapper Styles

Modify the values for each key under wrapper_styles to change how each part of the filename is wrapped. Use square brackets [], curly brackets {}, parentheses (), or an empty string for None.

Example: Studio-Title-Date.mp4 with a wrapper_styles of '[]' for each key --> [Studio]-[Title]-[Date].mp4

Separator

Modify the value of separator to specify the character used between different parts of the filename. Valid separators include hyphen -, underscore _, or space .

Key Order

Modify the key_order list to specify the order of keys in the filename. List the valid keys that can be included in the key_order.

Exclude Keys

Modify the exclude_keys list to specify keys that should be excluded from the filename formation process.

Move Files, Rename Files, and Dry Run

Modify the boolean values of move_files, rename_files, and dry_run to control the behavior of the script.

Exclude Paths

Specify custom paths that you would like untouched by Renamer.

Rollback.py - not supported in renamer-fork

renamer-fork does create a renamer.json file listing all renaming actions taken.

1 Like

Violation of the GPL license on GitHub…

this has been corrected now, license from the original repo has been added.

Required Information for GPL (and AGPL) Licensing

Copyright Notice:

- The author’s original copyright notice (e.g., “Copyright © [Year] [Author’s Name]”) must be retained.

- License text: The complete text of the GPL license must be included (often as a LICENSE or COPYING file).

Credits: The original developers or the “origin” author must be named in the documentation or “About” dialogs.