Over the past few days I’ve been reviewing GEDCOM files. As you can imagine this is very boring and GEDCOM files are difficult to read - ZZZzzzz.
So I created this AppleScript to help make a GEDCOM somewhat more “readable”. This AppleScript indents a Level 1 (e.g., NAME, BIRT, RESI, etc.) by one indent, it indents a Level 2 (e.g., DATE, PLAC, etc.) by two indents, and it indents a Level 3 by three indents, etc.
I would not suggest using the output file to import data into Reunion (or any other family tree-type application). It is purely used to make GEDCOM easier to read when reviewing a GEDCOM file. Indentation was added for readability only.
The enclosed AppleScript requires the text editor TextWranger (free) or BBEdit (cost $) to be available in your Applications folder to operate.
Details:
The idea for this came from “The GEDCOM Standard Release 5.5” (released in January 1996) at http://homepages.rootsweb.ancestry.c...om/55gcch2.htm
The example found was located in Chapter 2 under the section titled "Sample Lineage-Linked GEDCOM Transmission"
This AppleScript will indent up to 5 Levels (mostly CONC) since that is all I found when looking thru my Reunion & Ancestry.com GEDCOM files. The AppleScript can be easily modified to do additional Levels.
You can download TextWrangler at http://www.barebones.com/products/textwrangler/
Place TextWrangler or BBEdit in your Applications folder and then run this Applescript.
A family tree with 1,400 individuals that produces a GEDCOM with 40,000 lines completes in about about 15 seconds.
Hope this helps someone!
Jon
PS - a special shout-out to MacScripter at http://macscripter.net/index.php for their excellent AppleScript forums.
So I created this AppleScript to help make a GEDCOM somewhat more “readable”. This AppleScript indents a Level 1 (e.g., NAME, BIRT, RESI, etc.) by one indent, it indents a Level 2 (e.g., DATE, PLAC, etc.) by two indents, and it indents a Level 3 by three indents, etc.
I would not suggest using the output file to import data into Reunion (or any other family tree-type application). It is purely used to make GEDCOM easier to read when reviewing a GEDCOM file. Indentation was added for readability only.
The enclosed AppleScript requires the text editor TextWranger (free) or BBEdit (cost $) to be available in your Applications folder to operate.
Code:
--
-- This AppleScript is to make a GEDCOM file somewhat more "readable".
-- It indents a Level 1 by one indent, it indents a Level 2 by two indents, it indents a Level 3 by three indents, etc.
-- This is based on an sample found in The GEDCOM Standard Release 5.5 (released in January 1996)
-- http://homepages.rootsweb.ancestry.com/~pmcbride/gedcom/55gcch2.htm
-- The sample was located in Chapter 2 under the title "Sample Lineage-Linked GEDCOM Transmission"
-- I would not suggest using the output file to import data into Reunion (or any other family tree-type application).
-- It is purely used to make GEDCOM easier to read when reviewing a GEDCOM file.
-- Indentation was added for readability only.
--
-- get GEDCOM file to operate on
set GEDinFile to (choose file with prompt "Choose GEDCOM File" of type {"ged"})
set file_to_copy to quoted form of POSIX path of GEDinFile
set GEDoutFile to (GEDinFile & " (w indents).txt" as string)
set target_file to quoted form of POSIX path of GEDoutFile
-- copy original GEDCOM file to a new file
try
do shell script "cp " & file_to_copy & space & target_file
on error errorMsg number errorNum -- Something bad happened
display dialog errorMsg & "
Error Number = " & errorNum
return
end try
tell application "TextWrangler" -- or "BBEdit"
open GEDoutFile -- open up the copy - we don't want to mess up the original!
-- Level 0
-- Look for the beginning of a new record. The beginning of a new record is indicated by a line whose level number is 0 (zero).
-- add a new line before a Level 0 - just to make it easier on the eye
--
replace "^(0 @[@A-Z]*)(.*$)" using "\\n&" searching in text of text document 1 options {search mode:grep, starting at top:false, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false}
-- Level 1
-- Look for Level 1 information
-- add a one tab before a Level 1 - just to make it easier on the eye
--
replace "^(1 [_A-Z][A-Z]*)(.*$)" using "\\t\\1\\t\\t\\2" searching in text of text document 1 options {search mode:grep, starting at top:false, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false}
-- Level 2
-- Look for Level 2 information
-- add two tabs before a Level 2
--
replace "^(2 [_A-Z][A-Z]*)(.*$)" using "\\t\\t\\1\\t\\t\\2" searching in text of text document 1 options {search mode:grep, starting at top:false, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false}
-- Level 3
-- Look for Level 3 information
-- add three tabs before a Level 3
--
replace "^(3 [_A-Z][A-Z]*)(.*$)" using "\\t\\t\\t\\1\\t\\t\\2" searching in text of text document 1 options {search mode:grep, starting at top:false, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false}
-- Level 4
-- Look for Level 4 information
-- add four tabs before a Level 4
--
replace "^(4 [_A-Z][A-Z]*)(.*$)" using "\\t\\t\\t\\t\\1\\t\\t\\2" searching in text of text document 1 options {search mode:grep, starting at top:false, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false}
-- Level 5
-- Look for Level 5 information
-- add five tabs before a Level 5
--
replace "^(5 [_A-Z][A-Z]*)(.*$)" using "\\t\\t\\t\\t\\t\\1\\t\\t\\2" searching in text of text document 1 options {search mode:grep, starting at top:false, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false}
save (GEDoutFile as alias)
end tell
Details:
The idea for this came from “The GEDCOM Standard Release 5.5” (released in January 1996) at http://homepages.rootsweb.ancestry.c...om/55gcch2.htm
The example found was located in Chapter 2 under the section titled "Sample Lineage-Linked GEDCOM Transmission"
This AppleScript will indent up to 5 Levels (mostly CONC) since that is all I found when looking thru my Reunion & Ancestry.com GEDCOM files. The AppleScript can be easily modified to do additional Levels.
You can download TextWrangler at http://www.barebones.com/products/textwrangler/
Place TextWrangler or BBEdit in your Applications folder and then run this Applescript.
A family tree with 1,400 individuals that produces a GEDCOM with 40,000 lines completes in about about 15 seconds.
Hope this helps someone!
Jon
PS - a special shout-out to MacScripter at http://macscripter.net/index.php for their excellent AppleScript forums.
Comment