Skip to content

Instantly share code, notes, and snippets.

@wlpotter
Created December 11, 2025 15:28
Show Gist options
  • Select an option

  • Save wlpotter/37dc148565cdcda1a0f97ea275895e84 to your computer and use it in GitHub Desktop.

Select an option

Save wlpotter/37dc148565cdcda1a0f97ea275895e84 to your computer and use it in GitHub Desktop.
Simple JS to run in the Zotero dev console for adding the "[Deprecated] " prefix to titles that have been deprecated
/*
- Runs on selected Zotero items, so make sure to filter to "_deprecated" tag
- Will check if the deprecated prefix has already been added, and skip those
*/
let ZoteroPane = Zotero.getActiveZoteroPane();
let selectedItems = ZoteroPane.getSelectedItems();
const deprecatedPrefix = "[Deprecated] ";
const items = [];
for (let i = 0; i<selectedItems.length; i++) {
// get the title of the item
let title = selectedItems[i].getField('title');
//if the title is already deprecated with the prefix, skip it
if(title.startsWith(deprecatedPrefix)) {
continue;
}
// otherwise prepend to the item's title and save changes
let deprecatedTitle = deprecatedPrefix + title;
selectedItems[i].setField('title', deprecatedTitle);
let itemId = await selectedItems[i].saveTx();
items.push(itemId); //adds true to the array or logs an error
}
return items;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment