: replacement with another character?

Support for Windows users
Post Reply
wharris623
Posts: 5
Joined: 17 Nov 2015, 12:35

: replacement with another character?

Post by wharris623 »

One more question cause you guys rock!

When naming a movie or tv show sometimes they will have a colon ":" in the name of it. Filebot validate fixes that by removing the ":".

Is there a way to in the file format line have it detect ":" and change it to a hyphen "-"

Thanks in advance!

Wes
User avatar
rednoah
The Source
Posts: 23002
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: : replacement with another character?

Post by rednoah »

You'll definitely find the answers in one of the examples, I checked:
viewtopic.php?f=5&t=2
:idea: Please read the FAQ and How to Request Help.
wharris623
Posts: 5
Joined: 17 Nov 2015, 12:35

Re: : replacement with another character?

Post by wharris623 »

Hi RedNoah, I saw that but what I wasn't sure of if that just replaces the source file names. What if the destination filename is being pulled from say THEMOVIEDB and it's title is like "Movie : Part 2" instead of it wanting to change to that I'd like it to just do like "Movie - Part 2" sorry if I'm RegEx ignorant but I'm trying to learn it, just slow on the uptake I guess.

Thanks!

Wes
User avatar
rednoah
The Source
Posts: 23002
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: : replacement with another character?

Post by rednoah »

We're talking about replacing characters in a String. That's no RegEx required. Does it matter where the String came from? n ... name, t ... episode title, fn ... filename, etc.

Solution:

Code: Select all

{n.replace(':',' -')}
@see viewtopic.php?f=5&t=2#p16614
:idea: Please read the FAQ and How to Request Help.
wharris623
Posts: 5
Joined: 17 Nov 2015, 12:35

Re: : replacement with another character?

Post by wharris623 »

Hey RedNoah,

So here's the string I'm using! Works like a champ!

TV Shows -

Code: Select all

{n.replace(':',' -')} - {s00e00} - {t.replace(':',' -')}{if (file.isSubtitle())'.eng'}
Movies -

Code: Select all

{n.replace(':',' -')} ({y}){' CD'+pi}{'.'+lang}{if (file.isSubtitle())'.eng'}
Just thought I'd share in case anyone else needed it. You are awesome!
JrGooNer
Posts: 20
Joined: 16 Mar 2016, 15:27

Re: : replacement with another character?

Post by JrGooNer »

Could you please help me and tell me how I can enter something in my code that replaces the colon ":" (which is not allowed in the file name) with a semi colon ";" (which is allowed in the file name)..

Here is the code I want to add it to.. (I don't want to change any thing else or any other characters)

{n.sortName().replaceTrailingBrackets()} {sxe} {t.replaceAll(/[?.]+$/).replaceAll(/[`´‘’ʻ]/, "'") .lowerTrail().replacePart(' ($1)')}
JrGooNer
Posts: 20
Joined: 16 Mar 2016, 15:27

Re: : replacement with another character?

Post by JrGooNer »

I still haven't been able to work out how to do this after a lot of messing around with my code. Could someone take a quick look and help me possibly as it's doing my head it now :?

EDIT; I did it! I was still just messing about with it like rednoah told me to and eventually I found that I just needed to copy and paste this - .replace(':',' -') and put it in my code. the problem before was I was tring to put the whole thing - t.replace(':',' -')} into it and it was clashing with something.

Anyway, here is the finished code that I am using now just in case anyone wants to use it that have the same trouble seeing as I took so long to get the exact code that I wanted.

It replaces : with ;
Takes out all other illegal characters
Changes 'part 1' to (1)
takes out 'the' or 'a' from name but leaves them in for title

So give you this - 'Gotham 2x17 Wrath of the Villains; Into the Woods'

Code: Select all

{n.sortName().replaceTrailingBrackets()} {sxe} {t.replaceAll(/[?.]+$/).replaceAll(/[`´‘’ʻ]/, "'").replace(':',';') .lowerTrail().replacePart(' ($1)')}
User avatar
rednoah
The Source
Posts: 23002
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: : replacement with another character?

Post by rednoah »

e.g.

Code: Select all

{n.replace(':', ';')}
You'll need to add that to all the expressions that might yield values with colon : in it.
:idea: Please read the FAQ and How to Request Help.
Post Reply