INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Need expression to strip out colons (':')  (Read 855 times)

muzicman0

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1239
Need expression to strip out colons (':')
« on: June 14, 2018, 01:27:41 pm »

I have a custom field that I use for an external script.  I use the series name of the video file to create a path.  The problem is that sometimes, the episode name may contain a colon, or a period at the end of the name.  currently, I have an expression (below) that treats each of these names individually, but would prefer a way to do this dynamically.  Is there a way to do this?  Current expression is:

Code: [Select]
T:\TV\If(isequal([Series], Marvel's Agents of S.H.I.E.L.D., 1), Marvel's Agents of S.H.I.E.L.D, If(isequal([Series], NCIS: Los Angeles, 1), NCIS_ Los Angeles, If(isequal([Series], 24: Legacy, 1), 24_ Legacy,[Series])))\Season PadNumber([Season],2)\
So, "Marvel's Agents of S.H.I.E.L.D." becomes "T:\TV\Marvel's Agents of S.H.I.E.L.D\Season 01\", or "NCIS: Los Angeles" becomes "T:\TV\NCIS_ Los Angeles\Season 02\"

Is there a way to do this without having to treat each series?  That way if I start recording a new series with a colon, it will just work.
Logged

RD James

  • Citizen of the Universe
  • *****
  • Posts: 1871
Re: Need expression to strip out colons (':')
« Reply #1 on: June 14, 2018, 03:13:22 pm »

Media Center should already be replacing colons with underscores automatically without having to do anything.
I actually have an expression which replaces semicolons with unicode characters because I don't like that behavior.

Code: [Select]
Replace([Name], :, ꞉)

The same thing should work for [Series] if you're wanting to replace colons with a different character.
Logged

muzicman0

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1239
Re: Need expression to strip out colons (':')
« Reply #2 on: June 14, 2018, 03:19:44 pm »

It will do that if it is a file name, but in my case, MC is not aware that is is an actual path, and I am passing the field to an external script.  I will try the "Replace([Name], :, ꞉)" and see if I can get it to work.
Logged

muzicman0

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1239
Re: Need expression to strip out colons (':')
« Reply #3 on: June 14, 2018, 03:36:22 pm »

That helped, I was able to change to expression to:

Code: [Select]
T:\TV\If(isequal([Series], Marvel's Agents of S.H.I.E.L.D., 1), Marvel's Agents of S.H.I.E.L.D, replace([Series], :, _ ))\Season PadNumber([Season],2)\
which handles colons for sure.  Unlikely that many series titles are going to end in a period, so I will handle those as a one off if they come about.
Logged

RD James

  • Citizen of the Universe
  • *****
  • Posts: 1871
Re: Need expression to strip out colons (':')
« Reply #4 on: June 14, 2018, 04:09:03 pm »

I think this should cover everything with a general rule:

Code: [Select]
ListBuild(1, /\,
        Replace(
                If(
                    IsEqual(Right([Series, 0], 1), /.),
                    RemoveRight([Series, 0], 1),
                    [Series, 0]
                    ),
                :, _
                ),
        Delimit(PadNumber([Season, 0], 2), , Season/ )
        )

It should also be easier to modify the structure in future, since it uses ListBuild() for folder paths.
Logged

muzicman0

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1239
Re: Need expression to strip out colons (':')
« Reply #5 on: June 16, 2018, 09:39:08 am »

So here is the final that seems to work:

Code: [Select]
T:\TV\ListBuild(1, /\,
        Replace(
                If(
                    IsEqual(Right([Series, 0], 1), /.),
                    RemoveRight([Series, 0], 1),
                    [Series, 0]
                    ),
                :, _
                ),
        Delimit(PadNumber([Season, 0], 2), , Season/ )
        )\

Thanks a ton for the help!
Logged
Pages: [1]   Go Up