Easiest way to apply tag to a collection subset

Hi - I have a collection of 900 items and would like to apply a single tag to 400 of them. I know the Key and the DOI for the 400 - I have them in Excel - but I'm not sure that there is a way to apply the tag in bulk and I'd like to avoid having to tag

A few possibilities:
1. Could I somehow search for the 400 keys or DOIs? Then I could drag the results onto the tag.

2. Import: Perhaps there is a way to import a tag by bringing in a CSV with the Key and the tag?

3. Creating a new collection with the 400 items and applying the tag to them. Then somehow merging this new collection with the old collection? I'd like to avoid having to check each duplicate one at a time.

Thank you for any ideas.
  • I think you should be able to use the Zotero Actions & Tags plugin with the following script (or edit it or find a better one):
    https://github.com/windingwind/zotero-actions-tags?tab=readme-ov-file
    https://github.com/windingwind/zotero-actions-tags/discussions/351
  • edited January 27, 2025
    I'm not sure how that script helps? Bulk-tagging isn't a problem — it sounds like @fitzmier already knows they can drag multiple items to a tag in the tag selector to assign it. The question is really just how to select items matching a set of DOIs.

    @fitzmier, if I'm understanding you correctly, you can just run something like this in Tools → Developer → Run JavaScript:

    var dois = [
    '10.1234/abcd',
    // DOIs go here
    ];
    var s = new Zotero.Search;
    s.libraryID = Zotero.Libraries.userLibraryID;
    s.addCondition('joinMode', 'any');
    for (let doi of dois) {
    s.addCondition('DOI', 'contains', doi);
    }
    var ids = await s.search();
    ZoteroPane.selectItems(ids);


    BTW I'm not sure what you mean by "keys". If you actually mean Zotero item keys, it's even easier:

    var keys = [
    'ABCD2345',
    // keys go here
    ];
    var ids = keys.map(key => Zotero.Items.getIDFromLibraryAndKey(Zotero.Libraries.userLibraryID, key))
    ZoteroPane.selectItems(ids);
  • edited January 28, 2025
    Thank you both - I didn't realize how powerful Zotero was!

    I ended up using the @dstillman approach for now, but will also look into @damnation actions and tags.

    For anyone else interested I had to fiddle with the javascript to adapt it to my use case. I should have mentioned in my original post, but this is for a public library. I wasn't sure how to change the advanced search parameters in the code to specify the group library collection...but as a work around I just made my active Zotero window the group collection and selected all the items...then I used this code and looped through the items against an array of keys.

    var items = Zotero.getActiveZoteroPane().getSelectedItems();
  • edited January 28, 2025
    FWIW, instead of a script you can also chain the Keys in a Zotero select link of the form

    zotero://select/[user|groups]/[group/user ID]/items?itemKey=[itemkey1],[itemkey2],etc.

    So for your personal library that'd be
    zotero://select/user/881751/items?itemKey=[itemkey1],[itemkey2],etc.

    for a group it would be
    zotero://select/groups/[groupID]/items?itemKey=[itemkey1],[itemkey2],etc.
    and you can find the group ID e.g. by looking at the link to the group on zotero.org/groups

    Pasting that link in your browser will then select the items in Zotero.

    I've used this with 100 item keys at once, but I think it should handle 400 without issues.
  • edited January 28, 2025
    @adamsmith

    Thank you for the suggestion! I didn't understand at first but was able to figure it out.
Sign In or Register to comment.