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


  1. hi, maybe you would like our software “SciPlore MindMapping” which combines PDF management (including bookmark import) and mind mapping with your existing reference management software (e.g. JabRef/BibTeX, Mendeley and to some extent Zotero). on our website is also a video which gives a short demonstration.

  2. @Joran Thanks for letting me know.
    I had a look.
    Sciplore looks like interesting open source software.
    I'm not sure how well it would fit into my workflow, but it's definitely worthy of consideration, particularly for people who like mind mapping.

  3. Thanks for this info. Is there a way to import a folder of pdfs into JabRef. I just switched from Mendeley which was being buggy and slow, and I'm having trouble adapting to JabRef, couldn't find a way to tell it "here's the folder with all my pdfs." I'm on Ubuntu.

  4. Hi Adil,
    It depends what you mean.
    I link my PDFs to my references in JabRef.
    The easiest way to do this is to ensure that the pdf has the same file name as the BibTeX key of the reference (see the JabRef help for details).

    However, I don't think JabRef can do what Mendeley does: i.e., scan a folder and automatically extract bibliographic information from the PDF.
    However, you might be able to create a similar effect by exporting your references from Mendeley in BibTeX format and then using some form of file renaming process. I've never tried.

  5. @Adil
    You could check out c2bImport/c2bBib/c2bCiter ... it will read metadata from your pdf and store in a bib file... it takes a while but its quicker than by hand...