Difference between revisions of "Replacing GEDCOM media file paths"

From TNG_Wiki
Jump to navigation Jump to search
(added signature)
(Modified the regex find and replace values with more comprehensive versions)
 
Line 13: Line 13:
 
# Open the GEDCOM file in NotePad++
 
# Open the GEDCOM file in NotePad++
 
# Use menu item "Search > Replace" or hotkey Ctrl+H to open the "find and replace" dialog
 
# Use menu item "Search > Replace" or hotkey Ctrl+H to open the "find and replace" dialog
# In "Find what:" enter '''(?-s)^(\d+ FILE ).+/'''
+
# In "Find what:" enter '''(?-s)(?<=^\d FILE ).+(?=/)'''
# in "Replace with:" enter '''${1}/Smith_1234/''' where Smith_1234 is the new path
+
# in "Replace with:" enter '''/Smith_1234''' where Smith_1234 is the new path
 
# Set Search mode to "Regular expression"
 
# Set Search mode to "Regular expression"
 
# And I found it helpful to check "Wrap around" to make sure I caught them all
 
# And I found it helpful to check "Wrap around" to make sure I caught them all

Latest revision as of 10:55, 4 March 2022

As we all know, the file paths in a GEDCOM file are the local paths to the files on the user's computer and they need to be replaced with the server path.

There are tried and trusted methods for doing so, using tools inside TNG to make the process easier. For example, you can use Setup >> Configuration >> Import Settings and enter multiple paths to be substituted. I'm not going into that because the topic is covered by others, elsewhere.

But I have a particular use case where that would not be a suitable solution. It may be a bit of a niche use case but the solution may also be helpful to others so I decided to write it up.

My problem was that there were so many variations of file path that it was difficult and time consuming to find and enter them all. The problem was amplified by the fact I had to handle hundreds of GEDCOMs coming from all quarters, because our society, Berkshire Family History Society offers a service to users to host a copy of their family tree on our server.

Because there is no uniformity in the file paths of members' GEDCOMs, the native TNG solutions didn't work for me.

To solve the problem I turned to NotePad++ and the friendly help of their Community forum and we quickly established I could use Find and Replace in combination with regex expresssions. The process is really simple:

  1. Open the GEDCOM file in NotePad++
  2. Use menu item "Search > Replace" or hotkey Ctrl+H to open the "find and replace" dialog
  3. In "Find what:" enter (?-s)(?<=^\d FILE ).+(?=/)
  4. in "Replace with:" enter /Smith_1234 where Smith_1234 is the new path
  5. Set Search mode to "Regular expression"
  6. And I found it helpful to check "Wrap around" to make sure I caught them all
  7. Press "Replace all"

I should add that this solution works for us because we do not attempt to organise members' media into collections - everything goes into the TNG /photos/ folder, in a sub-folder for each user, because we have no control over how members use file types for different purposes. We see PDFs containing photos of people and JPGs containing photos of documents. It's an issue that's too hard to handle properly with our limited resources.

You can see the full thread on their forum here


Paul Barrett

Berkshire FHS