Jeromy Anglim's Blog: Psychology and Statistics


Monday, April 12, 2010

Exporting PDFs from JabRef using a Batch File

If you do research, JabRef is a great tool for managing a personal repository of PDFs. JabRef allows you to link your citations with full text PDFs. This post discusses one way of exporting a subset of your PDF repository using JabRef, Excel, and a Windows Batch file. This is useful (copyright permitting) in many situations.
For example:
(a) You need to extract a subset of references for a subject you are teaching.
(b) You need to give a colleague or research student a subset of your references.
(c) You want to transfer a subset of your references to another device or computer.

Option 1: Open and Save As

When there are fewer than five PDFs, it is quicker just to open the PDFs individually and save them in the desired location.

Option 2: Batch File Export

When there are more than five PDFs, it may be quicker to adopt a procedure like the following. The procedure involves creating a batch file to copy specified PDFs to a designated export folder.
The procedure is as follows:

1. In JabRef, Select PDFs of References that you want to export (see Figure 1).

2. In JabRef, Copy Selection (Edit - Copy)

3. In Excel, Paste into first column. Note: You could use a different Spreadsheet application, such as Open Office Calc.

4. In Excel, Sort the column alphabetically

5. In Excel, Highlight cells beginning with the word "file". Note: the "file" field is where JabRef stores the relative path for the PDF.

6. In Excel, Text to columns delimited by ":" Note: JabRef separates the data into file name, path name, and file type separated by colons. This step extracts the path name into it's own cell. If your repository does not include subfolders, file name will be equivalent to path name.

7. In Excel, Create the string to copy the batch file (see Figure 2).
7.a create the string "copy filePath destinationFolder" e.g., ="copy "&B24&" c:\temp", where B24 is the cell with the path name
7.b copy and paste this formula for the remainder of the cells.

8. In text editor, Create the batch file (see Figure 3).
8.a Open Notepad or another text editor
8.b the first line changes the directory to the root folder of your PDF repository. e.g., cd /d D:\My Documents\2Repository\filed
8.c Copy and paste the copy commands from Step 7 below this line.
8.d Save as a .bat file (e.g., copyPDFs.bat)

9. In Windows Explorer, Run the batch file. i.e., just double click the batch file.

Figure 1. Screen Shot of JabRef showing references with connected PDFs


Figure 2. Screen Shot of Excel showing Formula for creating copy command


Figure 3. Screen Shot of Notepad showing example of complete batch file