INTERACT FORUM

Please login or register.

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

Author Topic: Expression help  (Read 1452 times)

Mans

  • Galactic Citizen
  • ****
  • Posts: 418
Expression help
« on: December 27, 2019, 05:05:50 am »

Great day to all,

As I'm moving my pictures to MC aswell, I'm trying to figure out some things.
I could use some help on the following:

I've set up a view using "years" as top level, this works.
But when drilling down the next level isn't as labeled as i want.
It uses [date created] as [album] title instead of the existing foldername:

This is how the file path actually is:
.../2019/Mei/IMG_4011.JPG

So what I'm trying to achieve is:
-Setting auto-importing so the [album] tag is filled via an custom expression in order to carry the 'Mei' value of the file path.

The picture itself does carry the correct [name]: IMG_4011

I've tried playing with the RemoveRight and Delimit function, but as the filename (IMG_xxx or IMG_xxxx) isn't always the same length, the outcome isn't the one I'm wanting.

Thanks for your help !
Logged

Moe

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 718
  • Hi
Re: Expression help
« Reply #1 on: December 27, 2019, 10:58:11 am »

Assuming that the filepath before 2019 is simply the drive letter, I will use C as my example, try this bit of regex

Code: [Select]
regex([filename (path)], /#C:\\(.+)\\(.+)\\#/, -1)[R2]
Logged

Mans

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Expression help
« Reply #2 on: December 27, 2019, 01:24:39 pm »

Great day Moe,

Thanks for your help sir,

In fact the complete filepath is longer:
\\NAS1\photo\2019\Mei\IMG_3991.JPG

Where I'll only like to extract the part just in front of the filename.
photo is the dedicated share on my nas.
The year is the toplevel of the share and varies. This is why i tried to start from the end of the filepath by excluding the file name first and then some sort of delimiter in order to 'grab' the data.
Does it make sense ?

Another thanks Moe !
Logged

Moe

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 718
  • Hi
Re: Expression help
« Reply #3 on: December 27, 2019, 01:39:27 pm »

Try this

Code: [Select]
regex([filename (path)], /#.+\\photo\\(.+)\\(.+)\\#/, -1)[R2]
Logged

Mans

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Expression help
« Reply #4 on: December 27, 2019, 02:35:47 pm »

Great ! Works like a charm !
Thanks Moe.
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Expression help
« Reply #5 on: December 28, 2019, 03:51:10 pm »

It will come as no surprise to most here that I really dig Regex.  I use it for a lot of tasks.

But in this particular case, MC has a function that's designed to do the exact task the OP wants.

https://wiki.jriver.com/index.php/File_Path_and_Identifier_Functions#FileFolder

I'll leave it as an exercise for the reader (hi Moe!) to incorporate this into an expression the OP can use.

Brian.
Logged

Mans

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Expression help
« Reply #6 on: December 29, 2019, 04:06:48 am »

Many thanks to both of you, always surprised how rich MC features are :-)

=filefolder([filename,0], 0)
Does the job perfectly, easy :-)

Cheers !
Logged

MikeO

  • Citizen of the Universe
  • *****
  • Posts: 798
Re: Expression help
« Reply #7 on: December 30, 2019, 10:35:51 pm »

New Years resolution Learn Rebecca , I have put it off for years  :D
Logged

Moe

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 718
  • Hi
Re: Expression help
« Reply #8 on: January 03, 2020, 04:56:08 pm »

Cool, TIL that the FileFolder(…) expression exists :)
Logged

MikeO

  • Citizen of the Universe
  • *****
  • Posts: 798
Re: Expression help
« Reply #9 on: January 04, 2020, 12:59:18 am »

Of course I meant RegEx not sure who Rebecca is 🤫
Logged

Moe

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 718
  • Hi
Re: Expression help
« Reply #10 on: January 04, 2020, 12:44:47 pm »

MikeO, if you're serious about learning Regex, I highly recommend this site https://regex101.com/

While it won't "teach" you regex, it provides very valuable insight into the workings of regex.  I use it all the time.

As an example, using the above data, take a look at this https://regex101.com/r/pfdWM4/2

Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Expression help
« Reply #11 on: January 06, 2020, 09:51:22 am »

MikeO:

You might take a look at my little tutorial in Regex for MC:

https://yabb.jriver.com/interact/index.php?topic=97996.0

Brian.
Logged
Pages: [1]   Go Up