Skip to content

Instantly share code, notes, and snippets.

@FarisSquared
Last active June 26, 2023 06:12
Show Gist options
  • Save FarisSquared/080402aeb2a067b37426e71c884d73a9 to your computer and use it in GitHub Desktop.
Save FarisSquared/080402aeb2a067b37426e71c884d73a9 to your computer and use it in GitHub Desktop.
Zotero delete all tags batch

Zotero Delete All Tags

Simple and easy steps to remove all the tags in your Zotero Library.

The script works on the library you last selected or interacted with. it does not work on collections (you can modify it to do what you need.)

Steps:

  1. Ensure that your are using (Zotero 5).
  2. click on your library icon.
  3. click Tool (from the top).
  4. hover to Developer.
  5. click Run JavaScript.
  6. mark the check box "run as async function".
  7. Copy the code below and let it run.
  8. The script will rename all tags to "DELETE ME", Zotero will combine them.
  9. Delete the tag named "DELETE ME".
  10. Hit the Sync button (top righ corner).

Script

var libraryID = ZoteroPane.getSelectedLibraryID();

var tags =  await Zotero.Tags.getAll(libraryID);
var num_tags = tags.length;
var num_affected = 0;
for(let t of tags){
    
    await Zotero.Tags.rename(libraryID,t["tag"],"DELETE ME");

    num_affected++;
}

return "tag found: "+num_tags+" tags renamed: "+num_affected;

Disclaimer

not responsible for any data loss. This worked as intented on my machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment