Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

SQLITE Renamer for Stash

Using metadata from your database (SQLITE) to rename your file.

❗ Important ❗

By doing this, you will make definitive change to your Database and Files!

(You can have a logfile (USING_LOG), so you can probably revert everything...)

Requirement

Usage

  • I recommend make a copy of your database. (Use "backup" in Stash Settings)
  • You need to set your Database path (Line 9)
  • Replace things between Line 270 - 301

First Run

Set USE_DRY to True (Line 13), by doing this nothing will be changed.

  • This will create a file renamer_dryrun.txt that show how the path/file will be changed.

You can uncomment the break (Line 254), so it will stop after the first file.

Filename template

Available: $date $performer $title $studio $height

The script will replace these field with the data from the database. Exemple:

Template Result
$title Her Fantasy Ball.mp4
$title $height Her Fantasy Ball 1080p.mp4
$date $title 2016-12-29 Her Fantasy Ball.mp4
$date $performer - $title [$studio] 2016-12-29 Eva Lovia - Her Fantasy Ball [Sneaky Sex].mp4

Note:

  • A regex will remove illegal character for Windows.
  • If you path will be more than 240 characters, the script will try to reduce it. It will only use Date + Title.
  • If your height of the video is 2160/4320, it will be replace by 4k/8k else it will be height + p (240p,720p,1080p...)
  • If the scene contains more than 3 performers, $performer will be replace by nothing.

Change scenes by tags

If you want differents formats by tags. Create a dict with tag (The name of the tag in Stash) & filename (Filename template)

tags_dict = {
    '1': {
        'tag': '1. JAV',
        'filename': '$title'
    },
    '2': {
        'tag': '1. Anime',
        'filename': '$date $title'
    }
}

for _, dict_section in tags_dict.items():
    tag_name = dict_section.get("tag")
    filename_template = dict_section.get("filename")
    id_tags = gettingTagsID(tag_name)
    if id_tags is not None:
        id_scene = get_SceneID_fromTags(id_tags)
        option_sqlite_query = "WHERE id in ({})".format(id_scene)
        edit_db(filename_template,option_sqlite_query)
        print("====================")

If you only want change 1 tag:

id_tags = gettingTagsID('1. JAV')
if id_tags is not None:
    id_scene = get_SceneID_fromTags(id_tags)
    option_sqlite_query = "WHERE id in ({})".format(id_scene)
    edit_db("$date $performer - $title [$studio]",option_sqlite_query)

Change all scenes

edit_db("$date $performer - $title [$studio]")

Optional SQLITE

If you only want change a specific path, use the second parameter to edit_db(), it will add it to the sqlite query. (Documentation ?)

Exemple (Only take file that have the path E:\\Film\\R18):

option_sqlite_query = "WHERE path LIKE 'E:\\Film\\R18\\%'"
edit_db("$date $performer - $title [$studio]",option_sqlite_query)