Page 1 of 1

Deal with escape chars when checking for matches

Posted: 19 May 2025, 15:21
by udelledo
Hello folks,

I have my data split across three different paths (NAS), and I try to keep efficient, and organized.

I have come up with a formatting pattern that would:
* Check if the media that should be renamed is alread present in one of the three possible locations
* If the media is not present, the script should pick up the location that has more space available at the time of the move

Groovy: Select all

{["/path_1", "path_2", "path_3"]
        .collect{"$it/Shared Videos/Serie TV/$n" as File}
        .sort{ a, b -> a.exists() <=> b.exists() ?: a.diskSpace <=> b.diskSpace }
        .last()
}/{"Season "+s}/{n} - {s00e00} - {t}{'.'+lang.ISO2}
Up until now I never realized that this script has a "bug" when the name includes characters that are not accepted, and gets validated in a second step (i.e. : or ?), the lookup for existing resources fails (because the name is different)

Is there any method that I can use to sanitize the expected name already when renaming the pattern?

Re: Deal with escape chars when checking for matches

Posted: 19 May 2025, 18:06
by rednoah
Replace : colon with - dash and Replace Characters, Words or Patterns will get you started. You will likely need to sanitize each usage of {n} and {t}. Alternatively, the {plex} format generates Windows-compatible file paths by default.