Markdown link to annotation no longer work after convert linked files to stored files

After I converting linked files to Zotero stored files, clicking the markdown link that previously extracted(when pdf is in linked attachment state) will no longer jump to the annotation it points to. Is there a way to get away with this? have thousands of link like this and trying to convert all the linked attachment to stored files to leverage the ios reader....
  • Looks like it is because of the item ID change. Is it possible to assign the same item ID after conversion? or assign the same item ID if I check the option for deleting original file
  • edited April 15, 2023
    Not easily, sorry. It doesn't actually "convert" them, since that's not possible — it just creates a new stored-file attachment and deletes the old one.

    If you're comfortable writing some code, and you have a backup of the database from before the conversion (including one of the automatic backups in the data directory), it'd be possible to get the parent item of each item key in each link from the backup database and then rewrite each link with the item key of the main attachment from the post-conversion database.
  • edited April 15, 2023
    Basically, you could just load the backup database, output attachment item key → parent item key mappings from the Run JavaScript window (or just an SQLite client), and then do the same with the converted database.

    Then for each document you wanted to convert, take the plain-text doc as a string and replace each attachment key in the first map with the corresponding attachment key in the second map.
  • edited April 15, 2023
    Thanks for the quick reply I see high level it is pretty clear.
    It is just I need to learn some javascript and how to query that mapping, which looks like is not terribly bad.
  • edited April 15, 2023
    You can just run this on zotero.sqlite in an SQLite client:

    SELECT I1.key AS attachmentKey, I2.key AS parentKey FROM items I1 JOIN itemAttachments IA USING (itemID) JOIN items I2 ON (parentItemID=I2.itemID) WHERE I1.libraryID=1;
Sign In or Register to comment.