: replacement with another character?
-
- Posts: 5
- Joined: 17 Nov 2015, 12:35
: replacement with another character?
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
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
Re: : replacement with another character?
You'll definitely find the answers in one of the examples, I checked:
viewtopic.php?f=5&t=2
viewtopic.php?f=5&t=2
-
- Posts: 5
- Joined: 17 Nov 2015, 12:35
Re: : replacement with another character?
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
Thanks!
Wes
Re: : replacement with another character?
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:
@see viewtopic.php?f=5&t=2#p16614
Solution:
Code: Select all
{n.replace(':',' -')}
-
- Posts: 5
- Joined: 17 Nov 2015, 12:35
Re: : replacement with another character?
Hey RedNoah,
So here's the string I'm using! Works like a champ!
TV Shows -
Movies -
Just thought I'd share in case anyone else needed it. You are awesome!
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'}
Code: Select all
{n.replace(':',' -')} ({y}){' CD'+pi}{'.'+lang}{if (file.isSubtitle())'.eng'}
Re: : replacement with another character?
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)')}
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)')}
Re: : replacement with another character?
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'

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)')}
Re: : replacement with another character?
e.g.
You'll need to add that to all the expressions that might yield values with colon : in it.
Code: Select all
{n.replace(':', ';')}