INTERACT FORUM

Please login or register.

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

Author Topic: Help with directory template  (Read 1285 times)

paronsoda

  • World Citizen
  • ***
  • Posts: 102
Help with directory template
« on: January 02, 2018, 01:44:37 pm »

Hi

I'm trying to create a directory template that first checks if anything is written in the field [Series] and if it is it creates a directory with what's written in [Series]. If not, it checks the field [Name] and then creates a directory with what's written in [Name].

The reason I'm looking for this is that when I move files with the Library tools I don't want to change the Directory rule if I move TV series or movies. For example:

For TV series I need something like this
[Media Type]\[media sub type]\[series]\

And for a movie it need to be changed to
[Media Type]\[media sub type]\[name]\

I have tried to experiment with the "If(IsEmpty" function but havent had any success.

Thanks for any help
Hans
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8967
Re: Help with directory template
« Reply #1 on: January 02, 2018, 03:06:26 pm »

Something like:
Code: [Select]
[Media Type]\[media sub type]\if(isempty([series,0]),[name],[series])\
should work. I've posted before about why you need the ",0" in the field when using the rename tool. I'll link to it later when I have time to find it.

Before long, you should have a rename expression to move them all, regardless of media type etc. :)

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8967
Re: Help with directory template
« Reply #2 on: January 02, 2018, 11:34:12 pm »

found it...
Good stuff, glad that worked for you.

Re: isempty()...

If you imagine asking MC to create a directory structure using [series] without first testing its 'emptiness', and it was empty, MC would be attempting to create a directory with no name, which is not good. For this reason, if the field is actually empty, the rename tool replaces the emptiness with "Unknown [field]", and it does this before handing things over to the expression evaluator, meaning that as far as its concerned, the field is not empty.

You can use the same method to turn this off, ie...
Quote
[Media Type]\[Media Sub Type]if(isempty([series,0]),,[series])\if(isempty([album,0]),[name],[album])
You just need to be careful you're not asking MC to create illegal file paths or names, although in my testing, MC appears to gracefully and quietly correct any illegal double backslashes that appear in the new path, so you just lose a level in the path, which might not be what you want, but would be easy to correct.

-marko

Hopefully that helps a bit.

paronsoda

  • World Citizen
  • ***
  • Posts: 102
Re: Help with directory template
« Reply #3 on: January 03, 2018, 03:38:11 am »

Hi Marko

Thanks a lot! That was exactly what I was looking for.

Cheers
Hans
Logged
Pages: [1]   Go Up