Created
December 11, 2025 15:28
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| - 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