Mass edit via sql : how ?

Dear Zotero users end developers,

I tend to use a WebDAV tree to store (most of) my atachments and to attach a link to the relevant files in the Zotero entry for this dociment (this allows me to keep local access to the documents).

But my Storage has changed address : let's say that I have a lot of older items with attachments pointing to someplace.onthe.net, whereas new documents are stored on anotherplace.onthe.net (yes, that's the same tree on the same machine, whic has changed addresses).

Therefore, I'd like to mass-edit my database, changing all occurrences of "https://someplace.onthe.net/WebDAV/sone/tree/somedocument.pdf" with
"https://anotherplace.onthe.net/WebDAV/sone/tree/somedocument.pdf".

The relevant SQL query isn't hard to create, with help from SQLite and a bit of regex. I am aware that this should be done on a closed database (no Zotero instance running on the relevant computer).

But I have two problems :

1) What are the relevant fields in the Zotero database for a "personal" (= not shared) library ?

2) How to proceed with a group library ?

Any pointers to the documentation of the database structure would be appreciated.

Sincerely,

--
Emmanuel Charpentier
  • we strongly recommend against using SQLite to change databases. The easiest way to do this is just via Zutilo, which has a function for batch-changing links:
    https://addons.mozilla.org/en-us/firefox/addon/zutilo-utility-for-zotero/
    If you do want to code it yourself, use the javascript API (which is what Zutilo does under the hood).


    Not sure about your 2nd question, though, since attached links in groups don't exist in Zotero.
  • Dear Adam,

    Thank you very much for pointing me to Zutilo, which I didn't know. The ability to add the same marker to a bunch of references alone is something I longed for for a long time... This is enough to keep it.

    Hiwever, it does not solve my problem :

    1) Zutilo doesn't seem to be able to change *links* (that's what I have for most of my docs : links to files in a WebDAV directory, reachable via Web without having to mount anything : much easier to share...).

    2) I do not understand what you mean by "...attached links in groups don't exist in Zotero" : in my group libraries, most of the attached documents are, similarly, *links* to files in a WebDAV directory i.e somethong displayed in the interface as a page with a chain link in the bottom, which, when selected, displays a web address in the right panel, same as in my personal library).

    What would you suggest to update these links ? I do not (yet) know JavaScript. SQL and regexes, I know. Hence my idea (working with a safe backup of zotero.sqlite, of course...).

    Sincerely yours,

    --
    Emmanuel Charpentier
  • Oh, I didn't realize these were web links. Then what I said doesn't apply. I'm away from my regular setup, someone else should be able to get you the js code easily.
  • Dear zuphil,

    Yeah, that's something like this I'm looking for.

    Remaining problems :
    1) Learn enough javascript to be able to edit the correct part of a string (is there a regex library for javascript ?).
    2) Find how to reach for the attachment part of an item.
    3) Find how to reach a group collection.

    Any pointers ?

    Thanks again !

    --
    Emmanuel Charpentier
Sign In or Register to comment.