Batch adding PDF links

I have a Zotero database with about 3000 entries that was imported from a bibtex listing. I also have about 2000 PDFs that I would like to associate with the Zotero items.

I have been drag/dropping files onto the relevant Zotero item and using Zotfile to move the PDF file to the relative directory and create a linked attachment in the item. This works fine but is VERY slow.

I would like to know if there is a simple way to achieve this work flow programmatically; or to simply set many item linked attachment locations programmatically?

I breifly looked at the JavaScript API but couldn't find a good example of how this might be done.

Is this possible to do?


Zotero 4.0.21.5
FireFox 31
Windows 7
  • edited September 1, 2014
    I'm not quite sure which part you want to automate -
    dragging the PDF to the respective Zotero item would be pretty difficult to automate - you'd have to write code that lets Zotero find the right attachment for existing items. Not impossible, but certainly nothing quick.

    But renaming and moving the items, ZotFile can do in batch (and I though it'd just do it automatically). But if it doesn't do it automatically, just select all items in question and right click-->Manage attachments --> Rename Attachments
    That will also move them according to the rules specified in ZotFile.
  • Actually, it is the 'drag and drop' that I want to replace.

    I was wondering if, in JavaScript, you could do something using the linkFromFile(file,ID) function, such as:

    var Zotero = Components.classes["@zotero.org/Zotero;1"].getService(Components.interfaces.nsISupports).wrappedJSObject;
    var itemID = Zotero.Attachments.linkFromFile('C:\Zlib\MyPaper01.pdf', 2711)
    var itemID = Zotero.Attachments.linkFromFile('C:\Zlib\MyPaper02.pdf', 103)
    var itemID = Zotero.Attachments.linkFromFile('C:\Zlib\MyPaper03.pdf', 1902)
    :
    :


    Where the item ID would be extracted from the Zotero database, and the file path and name would be specified as the link?
  • you can take this to zotero-dev and see if someone is willing to answer there, but the short answer is that it's not quite as simple as that--your code, e.g, doesn't actually address finding the right pdf for the right item, which really is the main task here. But do realize that you're asking for a lot of help on a custom coding job here, so I wouldn't necessarily expect an answer.
    https://groups.google.com/forum/?fromgroups=#!forum/zotero-dev
  • Any update on when PDF drag-and-drop will be sped up? Still pretty slow. Thanks.
  • Speed-wise it's about as fast as it's going to get in the near future. Next major version will run it as a background process, though (or at least allow for that, not sure where they are with that) so that it doesn't freeze the browser.
    It's a little odd that you would still be dragging massive amounts of PDFs into Zotero after using it for this long?
Sign In or Register to comment.