INTERACT FORUM

Please login or register.

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

Author Topic: Evaluate FileFolder() from the left?  (Read 1036 times)

6233638

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 5353
Evaluate FileFolder() from the left?
« on: October 28, 2014, 11:28:30 pm »

Currently, FileFolder() works backwards up the tree.

So if your expression is: filefolder(c:\some\other\folder\a\, 2)
It will return "other".
 
However I have some paths where the number of sub-directories is variable.
For example "C:\Video\TV\Series\Season 1\"
If I use FileFolder(,1) that will return "Series"
 
But some TV shows only have a single season, so I have omitted the "Season 1" folder.
In this case the path is "C:\Video\TV\Series\" and FileFolder(,1) will return "TV" instead.
 
Is there any way that we could evaluate from the left rather than the right?
Perhaps using negative values?
 
Then FileFolder(,-3) would return "Series" for both paths. (there's a reason I want to evaluate the path rather than the series tag - this is just an example)
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Evaluate FileFolder() from the left?
« Reply #1 on: October 28, 2014, 11:42:05 pm »

That woul be cool. I'd prefer a new mode to the negative thing.

So, +1.

But, you can make your own version of filefolder() with the regular string parsing functions and listbuild() with delimit on \.  That's what we used to do before there was a built in filefolder() expression.

It was hard to go backwards before, but reasonably straightforward to read from left to right.  MrC has posted instructions before.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

6233638

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 5353
Re: Evaluate FileFolder() from the left?
« Reply #2 on: October 29, 2014, 07:38:10 am »

You're right, that's easy enough to do with:
 
ListItem([Filename, 0], 2, /\)
 
I suppose there's no need for any changes or new functions, since it's basic enough that anyone trying to write an expression should be able to figure it out.
 
Just didn't occur to me to use that.
 
So now I can distinguish between TV shows and Downloads, since videos downloaded from YouTube via MC end up with a [Media Sub Type] of "TV Show" but are in the \Downloads\ directory rather than \TV\
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Evaluate FileFolder() from the left?
« Reply #3 on: October 29, 2014, 08:08:55 am »

Yeah. ListItem.  I couldn't remember the exact details off the top of my head.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/
Pages: [1]   Go Up