INTERACT FORUM

Please login or register.

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

Author Topic: Help with expression to rename  (Read 5534 times)

yannis

  • World Citizen
  • ***
  • Posts: 229
Help with expression to rename
« on: June 24, 2016, 05:57:47 am »

Hi,

I'm trying to fix an expression to rename my video files, but I can't get right the If part right. Could you help?

This is the form I need, in plain english:

[Director] - [Name] - [Series (If Exists)] - [Season# (If Exists)] - [Episode# (If Exists)] - [Year] - [Subs]

Ideally, I'd like to include all directors like "Straub; Huillet", so the replace function you offered recently should come in handy.

I don't use "." or  " - " but there's plenty of "," and "-" in my columns.

Thanks in advance.
Logged

RD James

  • Citizen of the Universe
  • *****
  • Posts: 1871
Re: Help with expression to rename
« Reply #1 on: June 24, 2016, 08:31:29 am »

Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Help with expression to rename
« Reply #2 on: June 24, 2016, 08:43:16 am »

In my testing trying to do this, [Series] evaluates to "Unknown Series" when [Series] is empty.  I guess this has a reason for being there, but it messes things up in this case.  Using the same expression in an expression column, [Series] evaluates to empty (nothing shown) when it should be.

I think the only way to work around this is to define a new library field called something like [Rename] and make it calculated data with the expression you want.  Then use [Rename] in the RM&C tool.  I'm pretty sure that will work.

Delimit() isn't a bad way to do this, though it doesn't work exactly how I'd want it to.  The more messy idiom of:

if(!isempty([Series]), - [Series],)

...seems to work more consistently for me.

Brian.
Logged

yannis

  • World Citizen
  • ***
  • Posts: 229
Re: Help with expression to rename
« Reply #3 on: June 24, 2016, 08:55:03 am »

You did nail (part of) the problem, Brian. For many fields that are empty, MC defaults to "Unknown X", that is Unknown Year, Unknown Director etc, nulling the If exists I wanted to use.
Logged

RD James

  • Citizen of the Universe
  • *****
  • Posts: 1871
Re: Help with expression to rename
« Reply #4 on: June 24, 2016, 10:52:48 am »

I wonder if something changed because now it seems to require that ,0 is included. This should work:

Delimit([Series, 0], , / -/ )
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Help with expression to rename
« Reply #5 on: June 24, 2016, 11:00:39 am »

this works for me

listbuild(1, - ,[director],[series],[season],[episode],[year])

it returns something like:

pierre coffin;chris renaud - despicable me - 2010
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Help with expression to rename
« Reply #6 on: June 24, 2016, 11:05:07 am »

I wonder if something changed because now it seems to require that ,0 is included. This should work:

Delimit([Series, 0], , / -/ )

That works kinda sorta.  It includes literal / characters because RM&C is "special" and it doesn't work with the entire expression language.  That's why I said he needs to build a custom field to hold these expressions, then use that custom field in the rename expression.

Brian.
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Help with expression to rename
« Reply #7 on: June 24, 2016, 11:06:05 am »

this works for me

listbuild(1, - ,[director],[series],[season],[episode],[year])

it returns something like:

pierre coffin;chris renaud - despicable me - 2010

That doesn't work either because, in the RM&C tool, it inserts "unknown series" where there is no series.  Same thing for all of the rest.  It would probably work in a custom field, as I've suggested.

Brian.
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Help with expression to rename
« Reply #8 on: June 24, 2016, 11:16:26 am »

you are of course correct, i missed the RMC part, my bad

it does indeed work if you make a custom field (say [rename video]), use the expression, and then in RMC just type in [rename video]
Logged

RD James

  • Citizen of the Universe
  • *****
  • Posts: 1871
Re: Help with expression to rename
« Reply #9 on: June 24, 2016, 12:27:54 pm »

Code: [Select]
ListBuild(1, - , [Director,0], [Series,0], [Season,0], [Episode,0], [Year,0])
Should do what you want. I always forget about using ListBuild.

That works kinda sorta.  It includes literal / characters because RM&C is "special" and it doesn't work with the entire expression language.  That's why I said he needs to build a custom field to hold these expressions, then use that custom field in the rename expression.

Brian.
Works fine here, there's a "replace slashes in expressions" option that you may need to toggle though. (still works either way for me)
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Help with expression to rename
« Reply #10 on: June 24, 2016, 12:37:11 pm »

Works fine here, there's a "replace slashes in expressions" option that you may need to toggle though. (still works either way for me)

This is probably one of the subtle differences between the Windows and Mac versions of MC.  Because RM&C can't use quoting characters at all on my system.  Slash and /# #/ are both interpreted literally and do not perform the quoting function.  So your expression only partially works here.

I just hope the OP can use one or more of these techniques to solve his requirement.  Good luck OP.

Brian.
Logged

RD James

  • Citizen of the Universe
  • *****
  • Posts: 1871
Re: Help with expression to rename
« Reply #11 on: June 24, 2016, 12:47:22 pm »

This is probably one of the subtle differences between the Windows and Mac versions of MC.  Because RM&C can't use quoting characters at all on my system.  Slash and /# #/ are both interpreted literally and do not perform the quoting function.  So your expression only partially works here.

I just hope the OP can use one or more of these techniques to solve his requirement.  Good luck OP.

Brian.
Sounds like a Mac bug.
Logged

yannis

  • World Citizen
  • ***
  • Posts: 229
Re: Help with expression to rename
« Reply #12 on: June 24, 2016, 02:21:08 pm »

Code: [Select]
ListBuild(1, - , [Director,0], [Series,0], [Season,0], [Episode,0], [Year,0])
Should do what you want. I always forget about using ListBuild.

This one works as I want if I include spaces between ], 

But as I'm still learning, let me ask it can be fine-tuned: using it I get filenames like:

John Maloof; Charlie Siskel - Finding Vivian Maier -  -  -  - 2014.EXT

Is there a way it could skip completely the extra fields when they're empty, to give:

John Maloof; Charlie Siskel - Finding Vivian Maier - 2014.EXT   

?
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Help with expression to rename
« Reply #13 on: June 24, 2016, 02:46:17 pm »

works fine for me, doesn't leave any empty -

did you copypasta the code, or type it in with modifications?
Logged

yannis

  • World Citizen
  • ***
  • Posts: 229
Re: Help with expression to rename
« Reply #14 on: June 24, 2016, 04:06:15 pm »

You're right, if I copy RD's expression, it works as you say; but it stucks the - to the preceding field, as in:

John Maloof; Charlie Siskel- Finding Vivian Maier-   

So I tried to correct it and used this one:

ListBuild(1, - , [Director,0] , [Name] , [Series,0] , [Season,0] , [Episode,0] , [Year,0])

with extra spaces before the ,
and now I get the - - - as I said.
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Help with expression to rename
« Reply #15 on: June 24, 2016, 04:12:54 pm »

Try this expression:

Code: [Select]
ListBuild(1,/ - ,[Director,0], [Name], [Series,0], [Season,0], [Episode,0], [Year,0])
If that doesn't work in RM&C, put it into a custom field as I was saying before and I'm certain that will work, as I just tested it.

Brian.
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Help with expression to rename
« Reply #16 on: June 24, 2016, 04:15:35 pm »

I've tested this in RMC, it's working for me as advertised without any weirdness

Make sure it has " - ", as in a space before and after the hyphen

Logged

yannis

  • World Citizen
  • ***
  • Posts: 229
Re: Help with expression to rename
« Reply #17 on: June 24, 2016, 04:26:23 pm »

My eyes are closing, but as far as I can tell, this one did the trick; thank you all.
Logged

RD James

  • Citizen of the Universe
  • *****
  • Posts: 1871
Re: Help with expression to rename
« Reply #18 on: June 24, 2016, 08:09:20 pm »

Can we get some details of what system everyone is running this on?
It's very strange that everyone seems to be getting different results.
Having the "1" option set for ListBuild should have automatically ignored empty fields.

My system:
Windows 10 x64
JRiver 21.0.90
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Help with expression to rename
« Reply #19 on: June 24, 2016, 09:55:43 pm »

It does ignore empty fields...in an expression column or a custom field

It acts funky in RMC.  I was told a while back by guru glynor that this was due to RMC needing to handle lists differently

I do agree it's strange we seem to have different results but I suspect there are typos in the expression...
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9165
Re: Help with expression to rename
« Reply #20 on: June 25, 2016, 01:07:46 am »

Seems like you just about have this worked out. Lists can be tough to work with. The thing to remember about the RMC tool, is that it is mostly asked to create actual file paths, and these have to be legitimate, hence the reason "IsEmpty" doesn't work off the bat. The RMC does its own check first, and if it finds anything empty, it populates that with "Unknown" to prevent the tool from trying to create a folder with no name. Adding the ",0" switch inside the field tells the RMC tool that you know what you're doing, and to just use the raw field data instead...

RE: IfEmpty not working (from 2014)

-marko

yannis

  • World Citizen
  • ***
  • Posts: 229
Re: Help with expression to rename
« Reply #21 on: June 25, 2016, 02:54:19 am »

Thanks for explaining, it makes sense.

I'm on w7 64, accessing files over LAN to a w7 32.
Logged
Pages: [1]   Go Up