1

I was very happy to come across this answer: https://tex.stackexchange.com/a/212133/69378 which I hoped would allow me to Export only used items in a bibliography by making a call to jabref via the command line. I haven't been able to fully explore another answer to the same question (https://tex.stackexchange.com/a/41823/69378) which proposes bibexport (mainly because it's not available on MikTeX).

I prepped a windows command line command of the form: JabRef.jar -a filename[.aux],newBibFile[.bib]

which I interpreted to be: "F:\JabRef_3.6.jar" -n -a "test_article.aux","test_article.bib"

I have tried everything I can think of including all combinations of the preceding command and iteratively changing through:

  • omitting the -n to open the JabRef GUI
  • omitting the quotes
  • omitting the comma and using two arguments following the -a
  • using complete file paths for both files
  • removing file extensions and relying on the order to imply [.aux] and [.bib]
  • using the square brackets on the file names test_article[.aux] and test_article[.bib]
  • using new_test_article as the file name
  • having an empty test_article.bib file waiting in case the program can't create it, but just append
  • tested using JabRef-2.10.jar and JabRef_3.6.jar Difficulty Sadly, after iterating through everyone of these options nothing I do gives me a bib file.

UPDATE 1

My link in the comment below to where I found the syntax originated from an old server, their current FAQ (http://www.jabref.org/faq/) only describes the procedure:

Q: I have a JabRef database and I would like to export the subset corresponding to my LaTeX file. How to do this?

A: Upon compilation, LaTeX generates a file with the extension “.aux”. This files contains the keys of the cited references (among other things). Using this AUX file, JabRef can extract the relevant entries. Choose the menu Tools->New subdatabase based on AUX file. Then select the reference database (among the opened ones), and specify the AUX file.

I can confirm that this manual approach works fine.

The main difference between the steps in the GUI found in Tools -> New subdatabase based on AUX file is that you also must provide a reference bib file. I find it likely that the command line version, if it is still available, will require a reference bib file as well.

Update 2

New link with the updated command line configurations: https://help.jabref.org/en/CommandLine

I now use a command of the form JabRef.jar --aux "infile.aux","outfile.bib" "base-BibTeX-file.bib"

where each file is provided with it's complete absolute file path and name.

Unfortunately, I still don't get a file.

Has anyone ever used this line and generated a bib file from a windows command line?

  • Do you get an error? Is any file created at all? (In the case where you don't make it.) Any output? Is there a --verbose or --debug or whatever option? Biber can do this in tool mode ... – cfr Sep 12 '16 at 22:56
  • @cfr Thanks! When I don't make the file ahead of time, there's no file created. Near as I can tell, in Jabref (http://jabref.sourceforge.net/help/CommandLine.php) there's no verbose or debug output command. It's command line capabilities are fairly minimal. In some of the conditions above (namely leaving out -n and the , I could get a null return dialog that only showed up with the GUI. But since I interpreted that as an excess argument that couldn't be processed because it wasn't a command formatted as the instructions indicated, I didn't detail it above. – EngBIRD Sep 12 '16 at 23:23
  • No clue, then. Sorry. I don't use JabRef. – cfr Sep 12 '16 at 23:46
  • 2
    The updated command line instructions are available at help.jabref.org/en/CommandLine. General JabRef help is also available at discourse.jabref.org – koppor Sep 13 '16 at 19:03
  • @koppor Thanks for pointing me towards the new command line arguments. I'm using complete and absolute file paths to all 4 of the relavant files (including jabref) but I'm still not getting an output bib. I updated my syntax in the question above. I don't suppose I am missing anything small like and = sign or something on the final argument i.e. base-BibTeX-file=base-BibTeX-file.bib? – EngBIRD Sep 13 '16 at 20:13
1

As discussed in the comments of the question, the command line feature for aux export works. The problem is rather that it provides no real output to the user and the operation fails silently if there are errors in the source bib file (apparently, there were duplicate keys). This should be improved and I opened an issue in JabRefs issue tracker.

The command line syntax of JabRef has undergone some changes and the version that currently works can be found on the help pages. On Windows, there are different executables you can use and you can invoke them in different ways, but the command line arguments are structured in the same fashion. You can either execute JabRef.exe, or JabRef-X.X.jar. Depending on the Java setup of your local machine, you might be able to execute JabRef-X.X.jar directly or might have to call Java explicitly, e.g., java -jar JabRef-X.X.jar (strongly preferred, reason see below).

EDIT: After some more investigation in this, I can say that the command line will work in all of the ways explained above, but the only way to get output on the command line is the java -jar way. So, if you want output, for instance because your operation fails, be sure to use java -jar JabRef-X.X.jar, possibly with the --debug option.

For the aux-based export discussed here, you need add the arguments -a or --aux. Also adding -n prevents JabRef from opening the GUI at the same time. The parameters of --aux are structured as follows: infile.aux,outfile.bib base-BibTeX-file.bib, where

  • infile.aux is the aux file containing the citations of the references which you want to export
  • outfile.bib is the file to which the references should be exported. This file will be overwritten if it exists
  • base-BibTex-file.bib is the file from which JabRef tries to read the bibliographic data of the references it tries to export

Paths can be absolute or relative, with the usual pitfalls depending on the operating system you need to take care of (spaces in paths, etc.). Also JabRef necessarily needs write permissions for outfile.bib.

To sum this up, the following command should work:

"F:\JabRef_3.6.jar" -n -a infile.aux,outfile.bib base-BibTeX-file.bib

1

The likely cause of the file failing to be created was duplication and hence ambiguity in the bibtex keys. Since I was working from a derived file that I never open in JabRef, I never saw warnings of duplicate keys/entries that need to be resolved.

Personally, I manage my references in theme specific bib files in project specific folders. For any of the projects I have active at any given time, I use a small java program to merge the bib files in the project folders into one combined file.

Since it's not appropriate to distribute references for other projects with this one, I wanted to add a command to by bibtex compile script (bat file) that would then produce bib files of my compiled references as they are used in the document.

The final script, a little more versatile than my test paths above:

@ECHO OFF

:CheckOS
IF "%PROCESSOR_ARCHITECTURE%"=="x86" (GOTO 32BIT) ELSE (GOTO 64BIT)

:64BIT
ECHO 64-bit compiling
SET MikTexPath=C:\Program Files\MiKTeX 2.9\miktex\bin\x64\
GOTO END

:32BIT
ECHO 32-bit compiling
SET MikTexPath=C:\Program Files\MiKTeX 2.9\miktex\bin\
GOTO END

:END

:: changed bu*.aux to *.aux to make bibtex bibunit independent
FOR %%B IN (*.aux) DO ( ECHO Will try and compile %%~dpB%%~nB with %MikTexPath%bibtex & "%MikTexPath%bibtex.exe" "%%~dpB%%~nB")

:: --aux infile[.aux],outfile[.bib] base-BibTeX-file
FOR %%B IN (*.aux) DO ( ECHO "Will try and create a reduced bib file (%%~dpB%%~nB.bib) from %%~dpB%%~B with jabref." & "JabRef_3.6.jar" -n --aux "%%~dpB%%~B","%%~dpB%%~nB.bib" "..\References\CombinedBibFile.bib")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.