Page 1 of 2
re naming source/media files
Posted: 28 Jan 2020 01:05
by Johnande
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
Re: re naming source/media files
Posted: 28 Jan 2020 08:35
by Jane
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.
Re: re naming source/media files
Posted: 28 Jan 2020 10:06
by tatewise
If you need help with customising that Plugin then please ask.
Re: re naming source/media files
Posted: 28 Jan 2020 16:24
by Johnande
Thanks for the info Jane and "tatewise", Imay well have call on your expertise. Johnande
Re: re naming source/media files
Posted: 28 Jan 2020 18:17
by Johnande
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)
Re: re naming source/media files
Posted: 28 Jan 2020 18:39
by Jane
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.
Re: re naming source/media files
Posted: 28 Jan 2020 19:15
by tatewise
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.
Re: re naming source/media files
Posted: 29 Jan 2020 01:35
by Johnande
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)
Re: re naming source/media files
Posted: 07 Jan 2021 17:44
by judecosh
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
Re: re naming source/media files
Posted: 07 Jan 2021 18:05
by tatewise
Jude, it would help if you let us into the secret of what that plugin is called
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.
Re: re naming source/media files
Posted: 07 Jan 2021 20:13
by PyreneesPirate
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..
Re: re naming source/media files
Posted: 07 Jan 2021 20:48
by tatewise
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 _
Re: re naming source/media files
Posted: 08 Jan 2021 10:25
by Martin Tolley
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).
Re: re naming source/media files
Posted: 08 Jan 2021 13:21
by tatewise
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?
Re: re naming source/media files
Posted: 08 Jan 2021 13:48
by Martin Tolley
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.
Re: re naming source/media files
Posted: 08 Jan 2021 15:24
by tatewise
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!
Re: re naming source/media files
Posted: 08 Jan 2021 16:17
by Martin Tolley
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?
Re: re naming source/media files
Posted: 08 Jan 2021 16:30
by tatewise
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.
Re: re naming source/media files
Posted: 08 Jan 2021 17:01
by Martin Tolley
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
Re: re naming source/media files
Posted: 08 Jan 2021 17:18
by tatewise
If the punctuation means the Title and the filename are not identical in the first 30 characters then that would explain it.
Re: re naming source/media files
Posted: 08 Jan 2021 19:44
by PyreneesPirate
Sorry for the late reply and thanks for the info Mike.....tomorrow, I will give it a go and try to Edit the plugin.

Re: re naming source/media files
Posted: 31 Jan 2021 17:06
by judecosh
tatewise wrote: ↑07 Jan 2021 18:05
Jude, it would help if you let us into the secret of what that plugin is called
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 (

), 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

Re: re naming source/media files
Posted: 29 Jan 2022 00:50
by sbell95
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!
Re: re naming source/media files
Posted: 29 Jan 2022 11:38
by tatewise
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.
Re: re naming source/media files
Posted: 30 Jan 2022 02:01
by sbell95
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.