Skip to content

Instantly share code, notes, and snippets.

@anjiro
Created October 21, 2019 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anjiro/9e9e86c751b10e93b94c07d5ab608156 to your computer and use it in GitHub Desktop.
Save anjiro/9e9e86c751b10e93b94c07d5ab608156 to your computer and use it in GitHub Desktop.
Batch edit Zotero 5 items
//Make batch changes to selected items in Zotero. Paste this into Tools -> Developer -> Run JavaScript.
async function batch_edit(field, value)
{
var zp = Zotero.getActiveZoteroPane(); //Active Zotero window
var selected = zp.getSelectedItems(); //Get the items that are selected
for(const item of selected)
{
item.setField(field, value);
await item.saveTx();
}
}
//To check out the fields you can change, uncomment:
//return Zotero.getActiveZoteroPane().getSelectedItems()[0];
//Now run, for example:
await batch_edit("date", "1957");
return "Finished"; //This just prints "Finished" in the output window so you know it's done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment