Deal with escape chars when checking for matches

Any questions? Need some help?
Post Reply
udelledo
Posts: 8
Joined: 28 Oct 2013, 20:44

Deal with escape chars when checking for matches

Post 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?
User avatar
rednoah
The Source
Posts: 23990
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Deal with escape chars when checking for matches

Post 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.
:idea: Please read the FAQ and How to Request Help.
Post Reply