* Media File Names in queries

Questions regarding use of any Version of Family Historian. Please ensure you have set your Version of Family Historian in your Profile. If your question fits in one of these subject-specific sub-forums, please ask it there.
Post Reply
avatar
Little.auk
Famous
Posts: 224
Joined: 23 Jul 2021 08:51
Family Historian: V7
Location: Tamworth, Staffordshire, UK

Media File Names in queries

Post by Little.auk » 31 May 2022 13:02

I have my Media files split into sub-directories in the MEDIA folder.

I have a Multimedia query that uses the Expression %OBJE.FILE[1]% which returns the path and file name e.g. Media\BMD Records\05-Marriages\Parish Records\Marriage (PR) DOHERTY Thomas - BARLOW Ada J [FAM-088].jpg

Is there any Function \ Expression that will give me just the file name without the path?
Peter Rollin
Running FH 7.0.20 and AS 7.7.7 64 bit in Windows 11

User avatar
tatewise
Megastar
Posts: 27088
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Media File Names in queries

Post by tatewise » 31 May 2022 13:17

The best I can think of is the =Section(...) function using the \ folder separator.
e.g.
=Section( %OBJE.FILE[1]%, 5, "\" ) should return Marriage (PR) DOHERTY Thomas - BARLOW Ada J [FAM-088].jpg for your example, but depends on there being 4 parent folders. Unfortunately there is no option for last section.

If there are only a few variations in the depth of parent folders then you could use =TextIf(...) to cope with that.
e.g.
=TextIf( Section( %OBJE.FILE[1]%, 5, "\" ) = "" , Section( %OBJE.FILE[1]%, 4, "\" ) , Section( %OBJE.FILE[1]%, 5, "\" ) )

Further nested TextIf(...) functions can cope with 3 folders, 2 folders, etc.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
Little.auk
Famous
Posts: 224
Joined: 23 Jul 2021 08:51
Family Historian: V7
Location: Tamworth, Staffordshire, UK

Re: Media File Names in queries

Post by Little.auk » 01 Jun 2022 09:45

Thanks Mike,

I knew there wouldn't be a simple answer!

My longest paths in my Media folder are 7 levels deep, so I decided to build from the bottom up. I found the easiest way to keep the syntax right was to start with the expression
=TextIf(Section(%OBJE.FILE%,3,"\") = "",Section(%OBJE.FILE%,2,"\"),"END") (as the MEDIA Root directory contains directories only). I then replaced "END" by cutting and pasting the "TestIf" expression, and updating the numbers. It only took a minute or so to nest as far as TextIf(Section(%OBJE.FILE%,8,"\")="", a level more than I have actually got. I then changed the final "END" to "MORE DIRECTORIES!" as a prompt should I exceed the current number of levels.

It works perfectly, thank you - I have now used it with Section(%SOUR.OBJE>FILE%,3,"\") to extract the file names in a Sources query.
Peter Rollin
Running FH 7.0.20 and AS 7.7.7 64 bit in Windows 11

avatar
Little.auk
Famous
Posts: 224
Joined: 23 Jul 2021 08:51
Family Historian: V7
Location: Tamworth, Staffordshire, UK

Re: Media File Names in queries

Post by Little.auk » 01 Jun 2022 18:16

Hi Mike,

The Section(...) Function is so useful!

I am using AS and I use " : " (SPACE COLON SPACE). to split the elements of my customised Source Titles as per -

Baptism : Ryhill, Yorkshire, England :7 Mar 1897 : ROLLIN Sarah : [A0004-0001]

I wasn't sure that the Section function would accept " : " as the section separator - but it does! So that's a method for extracting data from Source Titles taken off my Wish List!
Peter Rollin
Running FH 7.0.20 and AS 7.7.7 64 bit in Windows 11

User avatar
tatewise
Megastar
Posts: 27088
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Media File Names in queries

Post by tatewise » 01 Jun 2022 19:30

Peter, I hope you know where to find the details of what each function offers.
In FH, open Help > Family Historian Help
Then in the Contents open General Topics + Advanced Topics + Understanding Functions + Functions (all)
Then select the function such as Section where it says it allows one or more characters as separator characters to define the 'boundaries' of each section.

You will find other useful help pages nearby.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
Little.auk
Famous
Posts: 224
Joined: 23 Jul 2021 08:51
Family Historian: V7
Location: Tamworth, Staffordshire, UK

Re: Media File Names in queries

Post by Little.auk » 02 Jun 2022 09:17

I have both Understanding Functions and Understanding Expressions downloaded to my PC for easy access.

However, as I had already built the nested expression based on your example, I just tested "space-colon-space" myself -- Another example of "Reading the manual" being the last resort!
Peter Rollin
Running FH 7.0.20 and AS 7.7.7 64 bit in Windows 11

Post Reply