How to replace / \ in file (episode naming)

Any questions? Need some help?
Post Reply
ShadowTheGreat2
Posts: 3
Joined: 07 Mar 2026, 13:24

How to replace / \ in file (episode naming)

Post by ShadowTheGreat2 »

I have been using the following string and it has worked flawlessly for my needs. I have run into an issue though, Using the TVDB, at times there are episode names that will sometimes use the forwardslash or backslash (/ or \). I want to continue using the following string but have it be able to replace the forwardslash and backslash symbols to an "and" symbol instead (&) in addition to it's current function.

Format: Select all

{(n + '.'  + s00e00 + '.' + t).replace('<':'﹤','>':'﹥',':':'꞉','"':'“','/':'⁄','|':'⼁','?':'?','*':'﹡','\\':'∖') }
User avatar
rednoah
The Source
Posts: 24475
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to replace / \ in file (episode naming)

Post by rednoah »

:?: Which series / episode are you testing with?

:idea: Note that all top-level bindings such as {t} are sanitised preemptively, i.e. cannot contain / or \ and thus cannot introduce accidental file / folder structure.

:arrow: You can use {episode.title} if you need the raw episode title value:

Format: Select all

{ episode.title.replaceIllegalCharacters() }
:idea: Please read the FAQ and How to Request Help.
ShadowTheGreat2
Posts: 3
Joined: 07 Mar 2026, 13:24

Re: How to replace / \ in file (episode naming)

Post by ShadowTheGreat2 »

Here is an example of what I am wanting to do

TVDB lists this episode as: Overkill/Left for Dead

{(n + '.' + s00e00 + '.' + t).replace('<':'﹤','>':'﹥',':':'꞉','"':'“','/':'⁄','|':'⼁','?':'?','*':'﹡','\\':'∖') }
(the string above) = The First 48.S01E02.Overkill Left for Dead

If possible, I would like to have the episode be renamed to: The First 48.S01E02.Overkill & Left for Dead
User avatar
rednoah
The Source
Posts: 24475
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to replace / \ in file (episode naming)

Post by rednoah »

e.g.

Format: Select all

{ n }.{ s00e00 }.{ episode.title.replace('/':' & ') }

Code: Select all

The First 48.S01E02.Overkill & Left for Dead
:idea: Please read the FAQ and How to Request Help.
ShadowTheGreat2
Posts: 3
Joined: 07 Mar 2026, 13:24

Re: How to replace / \ in file (episode naming)

Post by ShadowTheGreat2 »

Thank you for replying to my questions

If I am understanding you correctly I would need to use this string for 99% of my renaming needs

Format: Select all

{(n + '.'  + s00e00 + '.' + t).replace('<':'﹤','>':'﹥',':':'꞉','"':'“','/':'⁄','|':'⼁','?':'?','*':'﹡','\\':'∖') }
I will need to swap out the string with this for the other 1% that I would need

Format: Select all

{ n }.{ s00e00 }.{ episode.title.replace('/':' & ') }
I would not be able to combine both strings together for 100% for my needs, correct?
User avatar
rednoah
The Source
Posts: 24475
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to replace / \ in file (episode naming)

Post by rednoah »

ShadowTheGreat2 wrote: 08 Mar 2026, 21:30 I would not be able to combine both strings together for 100% for my needs, correct?
You can of course integrate my simple example code into your production code:

Format: Select all

{(n + '.'  + s00e00 + '.' + episode.title.replace('/':' & ')).replace('<':'﹤','>':'﹥',':':'꞉','"':'“','/':'⁄','|':'⼁','?':'?','*':'﹡','\\':'∖') }
:idea: Please read the FAQ and How to Request Help.
Post Reply