Page 1 of 1

How do I match information from the entire file path? (file name or folder name)

Posted: 24 Mar 2023, 22:47
by FTW
Hi

I would like to use a preset that could find a specific word in Folder name or in File name if it doesnt find it in folder (yeah because sometime, the folder name are badly named but the file name are correctly tag or vice versa)

Code: Select all

/data/output/{~plex.id % {" ${folder.name.matchAll(/(TRUEFRENCH)|\.(MULTi)\.|(SUBFRENCH)|(CUSTOM)|\.(QC)\./)}"}
how I could use the matchAll with that code too?

Code: Select all

${fn.matchAll(/(TRUEFRENCH)|\.(MULTi)\.|(SUBFRENCH)|(CUSTOM)|\.(QC)\./)}"}
so when it find the first match, it won't show the second one (sometime like a 'if cmd'

Code: Select all

if -> {" ${folder.name.matchAll(/(TRUEFRENCH)|\.(MULTi)\.|(SUBFRENCH)|(CUSTOM)|\.(QC)\./)}"} 
if don't find, look in ${fn.matchAll(/(TRUEFRENCH)|\.(MULTi)\.|(SUBFRENCH)|(CUSTOM)|\.(QC)\./)}"}
what's the best way I could ask it to do that kind of matching?

Thanks a lot taking your time to answer me

maybe the answer are much more easier than I though or I am too tired to find it by myself lol

Best Regards

Re: Need help with that preset

Posted: 25 Mar 2023, 11:33
by rednoah
You'll want to start rapid prototyping in the Format Editor and some test string / test file path:

Code: Select all

{ 'TRUEFRENCH.MULTi.SUBFRENCH.CUSTOM.QC.'.matchAll(/(TRUEFRENCH)|[.](MULTi)[.]|(SUBFRENCH)|(CUSTOM)|[.](QC)[.]/) }

Code: Select all

[TRUEFRENCH, MULTi, SUBFRENCH, CUSTOM, QC]

:arrow: You can then use f.path to access the file path as string value for any given file path and match information from there:

Code: Select all

{ f.path.matchAll(/(TRUEFRENCH)|[.](MULTi)[.]|(SUBFRENCH)|(CUSTOM)|[.](QC)[.]/) }

Re: How do I match information from the entire file path? (file name or folder name)

Posted: 29 Mar 2023, 15:50
by FTW
awesome, I will try it thanks