* re naming source/media files

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.
User avatar
Johnande
Silver
Posts: 7
Joined: 10 Apr 2006 10:06
Family Historian: V6.2
Location: Adelaide, South Australia

re naming source/media files

Post by Johnande » 28 Jan 2020 01:05

I have been using FH in all versions since it started. Before that, various other Genealogy programs were used.
Each have their own method of entering Source information. Now I only use FH version 6.2.7.
When I started Genealogy back in 1978, there were restrictions on the number of characters and symbols one could use.
Sometimes I named sources "Birth Certificate_John Smith", "Birth Cert John Smith", "BC1875 John Smith", "B1875_Smith John", etc. and the same for Marriage and Death Certificates.
I’ve used similar naming conventions for Letters, Newspaper Cuttings and other items..
All this information is stored in a "Media" file and I want to go through and rename all the data in one standard convention. Problem... by just renaming the individual files it will break the links with the main FH database. So All those links would have to individually reconnected...very boring and time consuming!
Can anyone come up with a solution to simplify this problem. I know my using better housekeeping in the first place would have not got me into this mess but!! Late I have learnt. Johnande
There is no future in getting old.
Getting old is for young people

User avatar
Jane
Site Admin
Posts: 8441
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: re naming source/media files

Post by Jane » 28 Jan 2020 08:35

I have attached a plugin which renames media files to the title of the media, plus the Object ID, so you might need to tweak it to match what you want. Please test it on a copy of your Project so you can customise it to what you need.
Attachments
Rename Selected Media Files.fh_lua
(1.37 KiB) Downloaded 187 times
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."

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

Re: re naming source/media files

Post by tatewise » 28 Jan 2020 10:06

If you need help with customising that Plugin then please ask.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Johnande
Silver
Posts: 7
Joined: 10 Apr 2006 10:06
Family Historian: V6.2
Location: Adelaide, South Australia

Re: re naming source/media files

Post by Johnande » 28 Jan 2020 16:24

Thanks for the info Jane and "tatewise", Imay well have call on your expertise. Johnande
There is no future in getting old.
Getting old is for young people

User avatar
Johnande
Silver
Posts: 7
Joined: 10 Apr 2006 10:06
Family Historian: V6.2
Location: Adelaide, South Australia

Re: re naming source/media files

Post by Johnande » 28 Jan 2020 18:17

I have downloaded the plugin that Jane sent. It appears to run but even after reading help info I cannot see how it works.
I've tried various approaches but nothing keeps happening! With the plugin running no way can I get the media editing to work. I'm sure it's finger trouble.
Any help would be appreciated. John (Johnande)
There is no future in getting old.
Getting old is for young people

User avatar
Jane
Site Admin
Posts: 8441
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: re naming source/media files

Post by Jane » 28 Jan 2020 18:39

When it runs it asks you for the media you want renamed on the disk. It will rename the media files to match the titles you have on the Media records.
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."

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

Re: re naming source/media files

Post by tatewise » 28 Jan 2020 19:15

In your original posting you talked about renaming the individual files, but realised that breaks the links.

The technique with this Plugin works the other way round.
Within FH in the Records Window open the Media tab where the Media records reside.
Open each Media record to be renamed in turn and edit its Title box as required.

When finished, select all the renamed Media records and run the Plugin.
It will edit each Media record and linked file so that the filename matches the Title.
BUT until it is adjusted, it also prefixes each filename with letter O, Record Id, underscore, e.g. O23_
By changing both the File link box and the filename itself the link is not broken.
FYI: NEVER use Edit > Undo Plugin Updates as that WILL BREAK the File Links.

Does that explain the process?

BTW: If you have some generic bulk name changes to Titles &/or File names then the Search and Replace Plugin might be useful, as it ensures the File name links are never broken.
e.g. If you want to replace every underscore with a space then this Plugin can do that throughout your Media.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Johnande
Silver
Posts: 7
Joined: 10 Apr 2006 10:06
Family Historian: V6.2
Location: Adelaide, South Australia

Re: re naming source/media files

Post by Johnande » 29 Jan 2020 01:35

Thanks for the info Mike. I think I've finally cracked it. Also managed to change the code to remove the leading "O", "Record ID", and "_". Thanks again for your help. John (Johnande)
There is no future in getting old.
Getting old is for young people

avatar
judecosh
Newbie
Posts: 4
Joined: 14 Apr 2017 13:57
Family Historian: V7
Location: Timperley, Greater Manchester

Re: re naming source/media files

Post by judecosh » 07 Jan 2021 17:44

The plugin Jane supplied last year has been working perfectly for me until I upgraded to the wonderful new version, is there anything I can do to get it working again please?

The error I get says "[string "C:\ProgramData\Calico Pie\Family Historian|PL...]":25: attempt to concatenate a nil value (global 'ext'). No changes have been made to data records.

Thanks

Jude

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

Re: re naming source/media files

Post by tatewise » 07 Jan 2021 18:05

Jude, it would help if you let us into the secret of what that plugin is called :D
Then one of us might be able to locate it and fix it.

Perhaps the Rename Selected Media Files attached earlier in Jan 2020 in this thread?

If so, then the attached updated version works for any FH Version.
Attachments
Rename Selected Media Files.fh_lua
Version 1.1 Date Jan 2021
(1.78 KiB) Downloaded 132 times
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
PyreneesPirate
Famous
Posts: 144
Joined: 06 Feb 2009 20:30
Family Historian: V7
Location: Montamat, SW France

Re: re naming source/media files

Post by PyreneesPirate » 07 Jan 2021 20:13

Hi just stumbled across this.....and it looks interesting.

Tried the Jan 2021 version and it worked very well on a media file.

Is there any way of removing the id code at the beginning and the underscores between the descriptors in the final file name, because that would be exactly what I require. I've looked at the edit plugin, it looked like I'd been typing with a French keyboard in English, so I jumped in the bin and didn't come out for five minutes..

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

Re: re naming source/media files

Post by tatewise » 07 Jan 2021 20:48

To make that change use Edit and then File > Save
The line to change is line 34:
local newfile = 'O'..id..'_'..string.gsub(fhGetItemText(ptr,strTitl),'[_%W]','_')..'.'..ext
which needs to be:
local newfile = string.gsub(fhGetItemText(ptr,strTitl),'[_%W]','')..'.'..ext
that omits the leading O and id and _ then later it replaces any non-alphanumeric with nothing instead of _
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
Martin Tolley
Diamond
Posts: 61
Joined: 02 Aug 2015 10:48
Family Historian: V6

Re: re naming source/media files

Post by Martin Tolley » 08 Jan 2021 10:25

Is there a way to do this "the other way around?" My media file names are correct - all files are external and I want them to remain where they are and with the names they have. My issue is that these worked fine with TMG, but the translation process into FH has kept the links but has truncated the Titles text to 30 characters (which I think is down to TMG). I have FH7, but for various reasons want to keep this project as FH6. I am less than clueless about plugins and programming them. There was a posting about this some five years ago and a plugin was mentioned to do this which I tried to download from the posting, but it doesn't seem to work (at least for me - see clueless above).

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

Re: re naming source/media files

Post by tatewise » 08 Jan 2021 13:21

Martin, can you clarify what you mean by "keep this TMG project as FH6".
Are you intending to have FH V6 installed on one PC and FH V7 on another PC?

You also need to clarify how you want Media Titles to 'mirror' the File Links.
The File Link will have a full Windows file path such as C:\Users\Martin\Pictures\image.jpg
Surely you don't want all that path as the Title?

Regarding import from TMG, certainly, FH would not truncate Media Titles as way more than 50 characters are allowed.
Could other TMG migrants please comment on the 30 character truncation?
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
Martin Tolley
Diamond
Posts: 61
Joined: 02 Aug 2015 10:48
Family Historian: V6

Re: re naming source/media files

Post by Martin Tolley » 08 Jan 2021 13:48

Mike
I have the same issue as reported in the posting "Truncation of Media filenames on import from TMG" posted back in 2015. My media window shows exactly the same problem as the screen posted by JohnLiddle » 08 Mar 2015 17:34
It seems to be a TMG problem, FH doesn't do the truncation, as described there.
I have a few databases for myself and clients, and this one I want to keep as FH6 on my main machine - IMO I'm not convinced that the upgrade to FH7 adds any functionality for me, and in some cases makes things more difficult. So I'm looking for a fix that works in FH6 for now, maybe migrating later, but unsure for now.

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

Re: re naming source/media files

Post by tatewise » 08 Jan 2021 15:24

Yes, that is a TMG problem.
So use the Filename to Title Plugin attached to that Truncation of Media filenames on import from TMG (12416) thread that solved the problem back then.
NOTE to others: This is an FH V6 only Plugin.

Strangely the phenomenon is no longer mentioned in Importing to Family Historian for TMG!
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
Martin Tolley
Diamond
Posts: 61
Joined: 02 Aug 2015 10:48
Family Historian: V6

Re: re naming source/media files

Post by Martin Tolley » 08 Jan 2021 16:17

Tried it, and it doesn't seem to do anything. Loaded the plugin - Run - and nothing happens. Is there something I should be doing more than that?

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

Re: re naming source/media files

Post by tatewise » 08 Jan 2021 16:30

What are you expecting it to do?

Have you checked the Media Titles?

Its criteria are that the first 30 characters of the current Title must match the first 30 characters of the filename.
If they do, then it changes the Title to match the filename excluding its file type.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
Martin Tolley
Diamond
Posts: 61
Joined: 02 Aug 2015 10:48
Family Historian: V6

Re: re naming source/media files

Post by Martin Tolley » 08 Jan 2021 17:01

OK. Some of them have been changed and some are still truncated. Can't see a complete answer but it looks as though there may be some punctuation in the original file name that upset the plugin? It's not a huge number that haven't been altered, I can manually sort those without too much bother
Thanks for the help

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

Re: re naming source/media files

Post by tatewise » 08 Jan 2021 17:18

If the punctuation means the Title and the filename are not identical in the first 30 characters then that would explain it.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
PyreneesPirate
Famous
Posts: 144
Joined: 06 Feb 2009 20:30
Family Historian: V7
Location: Montamat, SW France

Re: re naming source/media files

Post by PyreneesPirate » 08 Jan 2021 19:44

Sorry for the late reply and thanks for the info Mike.....tomorrow, I will give it a go and try to Edit the plugin. :oops:

avatar
judecosh
Newbie
Posts: 4
Joined: 14 Apr 2017 13:57
Family Historian: V7
Location: Timperley, Greater Manchester

Re: re naming source/media files

Post by judecosh » 31 Jan 2021 17:06

tatewise wrote:
07 Jan 2021 18:05
Jude, it would help if you let us into the secret of what that plugin is called :D
Then one of us might be able to locate it and fix it.

Perhaps the Rename Selected Media Files attached earlier in Jan 2020 in this thread?

If so, then the attached updated version works for any FH Version.
Sorry yes Mike it was the Rename Selected Media Files ( :oops: ), apologies for the delayed response, I forgot to tick notify when a reply is posted.....it clearly wasn't a good day! Thanks for the updated version and for the follow up post advising how to remove the O and ID :D

User avatar
sbell95
Famous
Posts: 107
Joined: 14 Feb 2021 06:04
Family Historian: V7
Location: Australia

Re: re naming source/media files

Post by sbell95 » 29 Jan 2022 00:50

tatewise wrote:
07 Jan 2021 20:48
To make that change use Edit and then File > Save
The line to change is line 34:
local newfile = 'O'..id..'_'..string.gsub(fhGetItemText(ptr,strTitl),'[_%W]','_')..'.'..ext
which needs to be:
local newfile = string.gsub(fhGetItemText(ptr,strTitl),'[_%W]','')..'.'..ext
that omits the leading O and id and _ then later it replaces any non-alphanumeric with nothing instead of _
I am currently working through renaming my media files and would like to use this plugin. However, I would like it to rename my media files with the FH media title exactly as it appears, e.g.:

Code: Select all

ALLOTT Emma 1839-10-27 Parish Baptism FMP
I tried editing line 34 as suggested, but could only work out how to replace the character between words, e.g. an underscore or space. How do I get the plugin to preserve both the spaces between words and the dashes for the date in my naming scheme?

Thanks!
Sarah Bell – Australia
View my tree on Wikitree

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

Re: re naming source/media files

Post by tatewise » 29 Jan 2022 11:38

The simplest solution is to eliminate the string.gsub(...) conversion entirely:
local newfile = fhGetItemText(ptr,strTitl)..'.'..ext

However, that will fail if any of your Media Titles contain any of \ / : * ? " < > | which are illegal filename characters.
So how do you want to handle those?
Remove them, or replace them with a space, or what?

That is why the string.gsub(...) conversion uses %W that matches any non-alphanumeric and substitutes underscore, but in your case also replaces hyphens and spaces with underscore.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
sbell95
Famous
Posts: 107
Joined: 14 Feb 2021 06:04
Family Historian: V7
Location: Australia

Re: re naming source/media files

Post by sbell95 » 30 Jan 2022 02:01

Thanks Mike. I don't have an issue with requiring special characters as none of my media file names (or any files for that matter) have those characters in them.
Sarah Bell – Australia
View my tree on Wikitree

Post Reply