Using metadata from your database (SQLITE) to rename your file.
By doing this, you will make definitive change to your Database and Files!
USING_LOG
), so you can probably revert everything...)Set USE_DRY
to True (Line 11), by doing this nothing will be changed.
rename_dryrun.txt
that show how the path/file will be changed.You can uncomment the break (Line 232), so it will stop after the first file.
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:
4k
/8k
else it will be height + p
(240p,720p,1080p...)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)
edit_db("$date $performer - $title [$studio]")
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)