INTERACT FORUM

More => Old Versions => JRiver Media Center 27 for Windows => Topic started by: Mans on December 30, 2020, 02:22:52 pm

Title: Expression help
Post by: Mans on December 30, 2020, 02:22:52 pm
Greatday,

Hoping you're all safe,

It seems i can't figure out how to delimit a filepath.
Like extracting only \\NAS1\Concert_Collection\ from the following filepath: "\\NAS1\Concert_Collection\Foo Fighters_ Live at Wembley Stadium (2008)\BDMV\"

I've been trying ListLimit, Filefolder and FileVolume but without success. RemoveRIght isn't an option due the variable length and sometimes their are additional levels.

I'm only after the Base Path, which is the name of my nas followed by the respective shared folder. Where the shared folder is the variable.

Another thanks for any pointers :-)

Take care and stay safe !
Title: Re: Expression help
Post by: lepa on December 30, 2020, 04:04:11 pm
I'm sure there are more elegant ways but this should work if "\\NAS1\" is a constant

Mid(\\NAS1\Concert_Collection\,0,Math(Find(\\NAS1\Concert_Collection\,\,7) + 1))

i.e. reds changed to filename path field
Mid([Filename (path)],0,Math(Find([Filename (path)],\,7) + 1))
Title: Re: Expression help
Post by: zybex on December 30, 2020, 05:32:34 pm
Try this - you can replace the {2} with the number of desired path elements:
regex([filename],/#(\\(.+?\\){2})#/,1)

To skip N elements and get the following K elements of the path:
regex([filename],/#\\(.+?\\){N}((.+?\\){K})#/,2)

To skip N elements and get all remaining text:
regex([filename],/#\\(.+?\\){N}(.*)#/,2)

A Replace([filename], \, ; ) can also be used to convert the path to a list of elements, which can then be manipulated with the list functions.
Title: Re: Expression help
Post by: Mans on December 31, 2020, 04:08:24 am
Many thanks dear Lepa and Zybex, you're both wizards !
You guys are truly the 'crème de la crème' of the Interact forum.

regex([filename],/#(\\(.+?\\){2})#/,1)
Works perfectly !

Enjoy the Year's end,

Take care and stay safe !
Title: Re: Expression help
Post by: lepa on December 31, 2020, 05:12:51 am
Try this - you can replace the {2} with the number of desired path elements:
regex([filename],/#(\\(.+?\\){2})#/,1)
This looks like easiest one to me for the problem in question

A Replace([filename], \, ; ) can also be used to convert the path to a list of elements, which can then be manipulated with the list functions.
Don't even need use Replace as ListItem takes delimiter in so one can use \ as delimiter instead of ;
\\ListItem(\\NAS1\Concert_Collection\,2,\)\ListItem(\\NAS1\Concert_Collection\,3,\)\

or with empty items removed:
Save(ListClean([filename (path)],3,\), v_PathElements)/
\\ListItem([v_PathElements],0,\)\ListItem([v_PathElements],1,\)\
Title: Re: Expression help
Post by: zybex on December 31, 2020, 07:54:06 am
Quote
Don't even need use Replace as ListItem takes delimiter in
Good point!

Happy new year, everyone  :)