Replace multiple characters?

All about user-defined episode / movie / file name format expressions
Post Reply
Azhrei
Posts: 3
Joined: 15 Jan 2020, 16:22

Replace multiple characters?

Post by Azhrei »

Here's my code currently:

Code: Select all

{n.colon('꞉ ')} - {s00e00} - {t.colon('꞉ ')}{if (ext == 'srt')'.en'}
In addition to colons, I'd like to have slashes replaced with a separate particular character but from what I've read, can't figure out how to accomplish both. Is there a way I'm missing? Any help would be appreciated, thank you!
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Replace multiple characters?

Post by rednoah »

e.g.

Code: Select all

n.colon(' - ').slash(' - ')
:idea: Please read the FAQ and How to Request Help.
Azhrei
Posts: 3
Joined: 15 Jan 2020, 16:22

Re: Replace multiple characters?

Post by Azhrei »

rednoah wrote: 15 Jan 2020, 18:55 e.g.

Code: Select all

n.colon(' - ').slash(' - ')
I tried that, but for the show in particular I'm attempting, it's not working regardless of the character I select to replace the /

Fate/Grand Order: Zettai Maju Sensen Babylonia
https://www.imdb.com/title/tt9525238/
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Replace multiple characters?

Post by kim »

There is no slashes to replace ;)

Code: Select all

{n}
Fate Grand Order - Absolute Demonic Front: Babylonia
btw: maybe try

Code: Select all

{plex.tail.derive{ext == 'srt' ? '.en' : ''}}
or

Code: Select all

{plex.tail.derive{ext == 'srt' ? '.en' : ''}.name}
OR

Code: Select all

{kodi.tail.derive{ext == 'srt' ? '.en' : ''}}
or

Code: Select all

{kodi.tail.derive{ext == 'srt' ? '.en' : ''}.name}
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Replace multiple characters?

Post by rednoah »

Ah, yes, there might be some top-level clean-up functions that apply to all bindings, such as removing / so you can't accidentally organize things into accidental folder structures.
:idea: Please read the FAQ and How to Request Help.
Azhrei
Posts: 3
Joined: 15 Jan 2020, 16:22

Re: Replace multiple characters?

Post by Azhrei »

Thanks for the replies. I tried switching to {plex.tail.derive{ext == 'srt' ? '.en' : ''}} but it changed where the file was located so I ended up keeping the if command. On a similar topic, I changed my code to:

Code: Select all

{n.colon('꞉ ').asciiQuotes().replace('?', '')} - {s00e00} - {t.colon('꞉ ').asciiQuotes().replace('?', '')}{if (ext == 'srt')'.en'}
Trying to rename this Dragon Ball Super episode:

Teacher and Student Reunited - Son Gohan and "Future" Trunks
https://www.thetvdb.com/series/dragon-b ... es/5656826

But the quotations don't appear in the rename. Am I misunderstanding what that .asciiQuotes() function does?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Replace multiple characters?

Post by rednoah »

:idea: String.asciiQuotes() will convert unicode quotes to ASCII quotes, replace “ ” with " " and ‘ ’ with ' ' and so on.

:idea: " is not allowed in file paths. If your format yields " as part of the file path, then it'll be removed. Both GUI and CLI should make that quite clear, either through a dialog, or via logging.
:idea: Please read the FAQ and How to Request Help.
Post Reply