CommunityScripts
CommunityScripts copied to clipboard
[renamerOnUpdate] Match and replace seems to not affect $title but $tags
I have a problem with the match/replace function. Replacing a string in the $title does not work for me.
Desired behaviour: Old filename example: "Test Video [tag 1 tag 2 tag3].mp4" I want to rename files based on a specific tag:
tag_templates = {
"tagging": "$title [$tags]"
}
New filename before regex: "Test Video [tag 1 tag 2 tag3] [tag 4 tag 5 tag6].mp4"
Also I want to remove the existing [$tags]-string from the filename, to avoid having a file name like that: "$title [$tags] [$tags]". For that I'm use this regex to match for the [$tags] pattern:
replace_words = {
r"\[[^\]]*\]": ["", "regex"]
}
expected filename after regex: "Test Video [tag 4 tag 5 tag6].mp4"
Actual behaviour: Renaming based on the tag_templates work but the regex is only applied to the newly added [$tags], not the the [$tags] which are already inside the filename ($title). So in fact there is no change to the filename then. I also tested with a simple "any or word" regex on part of the $title, with the same problem. "FHD" in the $title is untouched and "FHD" from $tags is correctly changed.
replace_words = {
"FHD": ["test", "any"]
}
New/old filename: "Test Video [tag 1 tag 2 tag3].mp4"
By the way I'm using: filename_as_title = True
but it also doesn't work if it's set to false. Also I do know that I potentially need to make the regex not greedy to avoid that both [$tags]-pattern are matched but for that it needs to affect the $title in the first place.
Is this as designed? If not, what could I try to fix it or if yes, what would I need to change in the "renamerOnUpdate.py" to make it work as expected?