Rename File on Update

This is a very simple version of other file renaming tools, made specifically for my needs. It is all configured through the Stash Plugins UI, no messing with configuration files is required. It also does not reach into the database internals at all and instead uses the built-in file renaming capabilities of Stash.

Note that this plugin is tested daily on a Linux machine running the bleeding edge version of Stash. I have no reason to believe it wouldn’t work elsewhere, but just know that I personally don’t test it elsewhere.

Plugin options

  • Allow unsafe characters: Enable this option if you want to allow the potentially unsafe characters for Windows filesystems. This option should fairly safe to enable with macOS and Linux.
  • Default directory path format: Formatted string to be used for the default directory to store files after they are moved. Note that this must be a directory that is contained within the directories for your Stash library, but it does not have to be the same root path as the original file. This can use any of the format specifiers mentioned below. Keep this blank in order to keep the file in the same directory.
  • Default file name format: Formatted string to be used for the default file name to rename the moved scene to. This can use any of the format specifiers mentioned below. Keep this blank in order to keep the original file name.
  • Dry Run: This controls if the files should be renamed or if they should just be indicated in the logs what they would be renamed to.
  • Duplicate file suffix: The suffix to append to the scene file names when a duplicate is found.
  • Remove extra spaces from file name: Should repeated spaces be removed from file names?
  • Rename unorganized scenes: Should this rename both organized and unorganized scenes, or only organized scenes?

File and directory formatting

This plugin offers a variety of format specifiers that can be used to customize the directory paths and file names which are generated.

Scene information

  • $director$: The director of the scene.
  • $title$: The title of the scene.
  • $scene_id$: The Stash scene ID for the scene.
  • $parent_studio_chain$: The name of the studio and the chain of parent studios of the studio attached to the scene.
  • $studio_code$: The studio code associated with the scene.
  • $studio_name$: The name of the studio directly attached to the scene.

Scene date

  • $date$: The scene date in yyyy-mm-dd format.
  • $month$: The month in mm format.
  • $year$: The year in yyyy format.

File information

  • $audio_codec$: The auto codec detected by ffmpeg.
  • $ext$: The extension of the file.
  • $height$: The height of the video.
  • $index$: The index of the file if it is a duplicate. This is empty for unique files and incremented by 1 for every duplicate file it detects.
  • $video_codec$: The video codec detected by ffmpeg.
  • $width$: The width of the video.

Optional parts of the path

There may be cases where you want the formatted value to be included if it’s present on the scene, but you don’t if it is not present. In these cases, you can wrap the section in curly braces ({ and }) to indicate that they should only be included if all of the format specifiers within it are filled in. If you do not indicate that it is optional, the format specifier will be replaced with an empty string instead.

Examples


If you run into an issue when using this plugin or have any questions, leave a message in this thread.