Exporting Endnote database into BibTeX format
Josh explains how to do this using JabRef. However, if you want to alter a document with a large number of existing Endnote citations, you may want to adopt a modified procedure. Below I set out the procedure that I adopted. However, I don't claim it to be the most elegant procedure. Nonetheless, it may give you some ideas.Changing Endnote Citations to BibTeX format
If you already have a document with Endnote citations, you are going to need to convert these citations to BibTeX format. If the document only includes a few citations, this conversion can be done manually with little effort. However, if you have a book or thesis with several hundred citations, you may want a quicker and more reliable method. The remainder of this post sets out a procedure that I adopted to transition my own Word document with around 500 unformatted Endnote citations to BibTeX format.This post assumes that:
- you have exported your document from a word processor into some preliminary LaTeX format.
- you have unformatted Endnote citations in the document
- you have JabRef installed
- you have some understanding of how Endnote, LaTeX, JabTeX, and BibTeX work.
Background
An unformatted Endnote citation typically looks like this:- Single Author and Year: {Author, Year #Record Number} : e.g., {Anglim, 2008, #231}
- Multiple Author and Year: {Author, Year #Record Number; Author, Year #Record Number} : e.g., {Anglim, 2008, #231; Smith, 2009, #100}
- Just Year: {, Year #Record Number} : e.g., {, 2008, #231}
- Author and Year with preceding text: {introductory text \Author, Year #Record Number} : e.g., {see \Anglim, 2008, #231}
- Author and Year with following text: {Author, Year #Record Number, following text} : e.g., {Anglim, 2008, #231, p.73}
Importing Endnote Record Numbers into JabRef
Step 1.
Read Josh's protocol but don't follow it just yet. The problem with this procedure is that it does not export the Record Number.Step 2.
Instead of following Josh's protocol exactly, the following modifies the protocol to include exporting of the Endnote Record Number. Create a copy of "BibTeX Export to JabRef.ens" and name it "BibTeX Export to JabRef RecordNumbers.ens"Step 3.
Modify the output style:- In Endnote go into edit this style "BibTeX Export to JabRef RecordNumbers.ens".
- Go to bibliography templates.
- For each Reference Type (e.g., Journal, Book, etc.) add an extra line with the following text:
`endnotekey = {`Record Number`},`
- Paste the above text just after the "URL" line is one option. E.g., it might look something like this in the area around the pasting:
`Abstract = {`Abstract`},` `Note = {`Notes`},` `URL = {`URL`},` `endnotekey = {`Record Number`},` `EndNoteRefType = {Journal Article},`
Step 4.
Return to Josh's protocol but use "BibTeX Export to JabRef RecordNumbers.ens" to export from Endnote. I.e.,- Highlight all rows of your Endnote Database and Export the references
- Use "BibTeX Export to JabRef RecordNumbers.ens" and File Export
- after exporting change the file extension of the exported file to ".bib".
- open the bib file in JabRef
Step 5.
After opening the BibTeX file in JabRef, add "endnotekey" as a field:- Menu: Options - Set General Fields
- Add the following to the end of the line that starts with "General: "
";endnotekey"
Step 6.
To enable you to see the Endnote Record Number in the main viewing table in JabRef:- Options - Preferences Menu
- Entry table columns
- Add (Plus)
- add the field "endnotekey"
Step 7.
Auto-generate a BibTeX key for all the imported references. In a previous post I discuss some of the issues regarding choosing a BibTeX auto-generation key.Manually Update Endnote Citations
At this point each unformatted endnote reference could be manually updated so that it refers to the appropriate BibTeX key. E.g., If you had an unformatted Endnote citation with Endnote Record Number like:{Bryan, 1897 #1366}
, you could do the following:
- Search for this record number in JabRef
- Control + F (to open Search in JabRef)
- "endnotekey=1366" (to get the specific article) OR simply "1366" (this may not always be unique but saves a little typing)
- Copy the BibTexKey:
Control + K would copy to the clipboard:
\cite{Bryan1897}.
- Paste over the unformatted Endnote citation in your LaTeX document.
Automatically Update Endnote Citations to BibTeX format
A more advanced alternatively involves automatically replacing[endnotekey]
with [bibtexkey]
throughout the LaTeX document.
There are many ways that this could be done.
The following is a fairly inelegant method using a combination of Excel and Word (see the bottom of this post for alternatives).
The post assumes that the hash symbol (#) followed by a number only occur in relation to Endnote citations.
1. Create a copy of your ".bib" file
- call it "copy.bib"
2. Copy the "endnotekey" field into the "note" field.
This is required because the "endnotekey" field is not included in a standard export.- Open "copy.bib"
- Tools - Set/Clear/Rename Fields
- Field name: "endnotekey" and Rename field to "note"
- OK
3. Export the JabRef Database to a Spreadsheet readable format.
- File - Export
- File of type: "OpenOffice CSV (*.csv); let's call it "bib.csv"
4. Open "bib.csv" in Excel
The following steps would presumably work in most other spreadsheet programs like Open Office, perhaps with some modification to the function.5. Create in Excel the code required for the VBA Word Procedure
The general format of the procedure is:ReplaceEndnoteRef EndnoteKey, BibtexKeywhere
ReplaceEndnoteRef
is the name of the procedure,
EndnoteKey
is the number of the endnote key,
and BibtexKey
is the BibtexKey.
For example, this could be:
ReplaceEndnoteRef 724, "Smith2008"
- To create this in your spreadsheet (with bib.csv) enter the following function in an extra column (it assumes that the "note" field is in column M and the bibtex identifier is in column C):
- Copy and paste the function so that it applies to all rows.
- Sort all rows by the "note" field in descending order. The code needs to be run in this order to avoid inappropriate replacements.
- Paste a copy of the LaTeX text into a New Word Document. WARNING: do not run this macro on your document without a backup.
- Apply a macro in Word
- Paste your latex text into a new word document
- Open up the Visual Basic Editor and paste the function below (insert a new module if needed)
Sub ReplaceEndnoteRef(EndnoteKey, BibtexKey) EndnoteKey = "#" & EndnoteKey Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = EndnoteKey .Replacement.Text = BibtexKey .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll End Sub
- Create a new procedure and paste the commands from Excel.
Here are the first few lines of such a procedure
Sub ReplaceRefs() ReplaceEndnoteRef 1495, "Sternberg1979AP" ReplaceEndnoteRef 1494, "Thoresen2004JoAP" ReplaceEndnoteRef 1493, "Lievens2002MEa" ReplaceEndnoteRef 1492, "Lievens2002ME" ReplaceEndnoteRef 1491, "Goldberg2006JoRiP" ReplaceEndnoteRef 1490, "Carroll1865" ReplaceEndnoteRef 1489, "Walsh2009CP" ReplaceEndnoteRef 1488, "Zimbardo1973NYTM" ReplaceEndnoteRef 1487, "Anglim2000" ReplaceEndnoteRef 1486, "Fry" ReplaceEndnoteRef 1485, "Anglim2007" ReplaceEndnoteRef 1484, "Zou2007PM" ' And many more references end sub
- run the ReplaceRefs() procedure on your document.
F5 is a shortcut key when the cursor is in the procedure.
This should automatically replace endnotekeys with bibtexkeys.
This still leaves a fair amount of text in the citation to tidy up, but it is at least a reasonable start. In addition the remaining text is likely to be relevant to how the text should appear (i.e., whether there is preceding text, or following text, and whether the authors names should appear).
If you continue to use this version of the database you may want to clear the "note" field so that the endnote key is no longer present. Otherwise it may appear in references. This can be done using the Tools - Set/Clear/Rename Fields menu option in JabRef.
="ReplaceEndnoteRef "&M2&", "&CHAR(34)&C2&CHAR(34)This should result in one cell that looks something like this:
ReplaceEndnoteRef 1294, "Abraham1992AoDPS"