Command line export filtering with multiple search terms


#1

My basic question is how to use a search term containing multiple different matches for one field in the command line interface of JabRef (e.g. timestamp = 2017.04.20 or 2017.04.21). The help page does not discuss this case, and in fact, the example given, (author=bock or title|keywords="computer methods")and not(author=sager) does not work for me.

I am currently trying to use the command line of JabRef to export entries in a custom format. I have this working for simple searches, but for searches where I want to include multiple options, I run into a problem.

Using java -jar C:/Path/To/Jabref/Jabref-3.8.2.jar --import C:/Path/To/Bibtex/file.bib,bibtex --exportMatches timestamp=2017.04.20,C:/Path/To/Export/File.customformat,customformat --nogui works as expected.

My current command is:
java -jar C:/Path/To/Jabref/Jabref-3.8.2.jar --import C:/Path/To/Bibtex/file.bib,bibtex --exportMatches timestamp=2017.04.20 or 2017.04.21,C:/Path/To/Export/File.customformat,customformat --nogui

If I use or between the search terms, I get errors that JabRef is unable to open the file or and 2017.04.21. If I use | between the search terms, I get the error that 2017.04.21 is not a recognized as an internal or external command, operable program, or batch file.

I am using Windows 10, Java version 1.8.0_121 and have tried this with both JabRef 3.8.2 and the 4.0.0 beta jar file.

Looking at the source code for exportMatches, there seems to be mention of search terms with spaces, but I cannot figure out how to get this to work, and I am not a Java expert.


(Nathan) #2

You can do this, but in my experience you need to put the exportMatches arg in quotes.

I think the exportMatches argument uses the same search functionality that you get in JabRef. So, first make a query that works in the JabRef search; then just paste that query into a quoted argument on the command line.

Here’s an example of one that works for me to grab all entries I’ve added in the last 3 months:

--exportMatches "timestamp=`date +%Y-%m` or timestamp=`date +%Y-%m -d '-1 month'` or timestamp=`date +%Y-%m -d '-2 month'`"

If you don’t quote it, then the shell is going to consume those as different arguments. So while JabRef search understands spaces, in your case the spaces are getting consumed by the shell and JabRef never sees them. The command line version of JabRef therefore gets confused about your arguments.