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

Any questions? Need some help?
Post Reply
FTW
Posts: 39
Joined: 28 Jan 2022, 09:47

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

Post 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
User avatar
rednoah
The Source
Posts: 22899
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Need help with that preset

Post 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)[.]/) }
:idea: Please read the FAQ and How to Request Help.
FTW
Posts: 39
Joined: 28 Jan 2022, 09:47

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

Post by FTW »

awesome, I will try it thanks
Post Reply