Import with attachment location

I'm trying to move my bibtex collection into zotero, and I'd like to preserve attachments and collection information is I do so. I've tried converting my bibtex files into zotero RDF, which seems to be the most rich format, but it's not picking up my attachments. When I export a sample zotero rdf, I see that it stores only file names to linked attachments, not full paths (and a round-trip of Zotero RDF also loses the attachments).

Is there a way for me to get Zotero to pick up these attachments by structuring the RDF differently, or another way to get my collection/attachment info migrated, other than direct writing into the sqlite database? If only the latter, is the DB format documented?

  • It depends on what you're trying to do:
    - If you're trying to attach _links_ to files via RDF (or any other) import then no, that's not possible. No, the sqlite isn't documented beyond the sourcecode, I _think_ this should be doable via the local API: , which is decently documented, but I haven't actually looked at attaching links.

    - If you're just trying to import files into Zotero via RDF or BibTeX import (i.e. the equivalent of "store copy of file"), that should just work, certainly roundtrip.
  • That's what I was trying to do, indeed. I'm looking at just patching things directly into the DB.

    Any idea what the column sourceItemID does? itemID links the attachment to the library item, so that's not it.
  • Modifying the database directly is strongly discouraged. If you do so, we won't be able to provide support for any future Zotero issues you face.
  • Alright, I'll look into the JS API.
  • edited July 30, 2013
    (But, to answer your question, sourceItemID is the itemID of the parent item of child attachments and notes. It's NULL for top-level attachments and notes.)
  • @emiliano : I'm not sure what you want. But, just in case, if you find how to import linked attachments (from bibtex or RDF, whatever), could you please, write your procedure? Some people already tried (, me too, but I can't find out how.

    By the way, the only solution, I found (which was very time-consuming), is to import with absolute links and convert them to attach links with Zotfile. Works fine but not if you have many folders, as you have to do them folder by folder.

  • What do you mean with absolute links? And how did you do it with zotfile? I might be able to automate zotfile through the JS API.
  • ZotFile can convert attachments stored in Zotero to linked attachments in a target folder. It can do so in batch.
    That would effectively mean moving files in and out of Zotero, though, rather than just linking to existing ones.
  • Adamsmith is more rapid than me. ;-)
    Yes, Zotfile can do the change from storage to attachments in batch. But ideally, it will be better if we can directly import as a "attachment.linkMode" than "item.attachments" (from what I understood in bibtex translator.js file). That way, we circumvent the folder problem (in Zotfile preferences, you decide in which folder your file is linked in, so basically it's easy if you have one big folder and tricky if you get more)
  • @mel47 if I succeed, I'll let you know.
    @Dan: do I need to take this sourceItemID into account for the JS api? I still don't really understand what it is meant to do; the attachment is already bound to it's item with the itemID, right?
  • Can I include paths in the RDF that will be imported as stored attachments?
  • rdf:resource takes both absolute and relative links, yes. Just tested to make sure & definitely imports attachments with Zotero 4.0.9
  • do I need to take this sourceItemID into account for the JS api?
  • Is it correct that the zotero RDF format is the only import format that allows specifying collection info?
  • yes, that's correct.
  • @mel47: I created a derivative from Zotfile at . If you install that *instead of, not alongside* zotfile, and enable the checkbox in "advanced settings" of zotfile, everything that resides in your basedir will automatically be linked instead of imported.

    I've submitted a pull request to the original author of zotfile, so perhaps it will be integrated; if not, I'll split it off to a separate extension.
  • @mel47: zotfile will not be integrating this change; I've created a separate extension that can safely be installed alongside (or without) zotfile, available at
  • Oh wow! I will try this ASAP and give you feedback.
  • A new version is now up that will auto-update when a new version becomes available.
  • Re-wow! It really do what I was looking for! To me, it will be useful to transfer my database (with links) to my collegues until links will be sharable via Zotero groups.
    Thanks for this work.
  • edited August 30, 2013

    does not work for me after installing the addon on standalone Zotero, unfortunately. Drag-n-dropping a PDF file on Zotero window, or importing a BibTeX file still leads to PDFs being copied (not linked) to Zotero storage dir.
  • Dear emilio.heyns,

    Thanks for updating the script. I had silly issues getting it to work initially, but as someone perhaps does the same mistake (maybe atenrok did?) I will say here.

    Being a zotero-stranger, it was easy to miss: "everything that resides in your basedir will automatically be linked instead of imported."

    I merely updated my base directory to where the files are, and now everything is working perfectly with all versions.

    Many thanks, this extension is amazing!
  • This extension saved my bacon too. I imported a library from Sente, through a Bibtex file, and I prefered to leave the files organized in my familiar thematic folder structure. Thanks to recent updates to the import filter of Sente-generated BibTex, even multiple attachments now get imported flawlessy as links.

    So, many thanks to Emiliano.

    PS. I still feel this would be a worthy option for Zotero, and it seems to be planned. FWIW, the option might be made context-dependent: if you import references after having specified a base directory for the relative path (in the Advanced preferences tab), the import would be relative links. Otherwise, the files would get copied. This could make a dialog unneccesary.
  • Here's the ticket:
    and yes it's definitely planned. The consensus implementation is a pop-up on import. Importing with files is relatively rare so this won't annoy users (if it turns out to be a problem there could be a "remember this setting" option, but not even sure that's necessary) and since a lot of the people affected by this will be first-time users, it'd be a bad idea to hide this behind a contextual solution. The base directory is also not strictly necessary for wanting to use linked files. You only need that if you want linked files on multiple computers.
Sign In or Register to comment.