How to delete the content of the extra field for all references
Hello,
A plug-in has filled the ‘extra’ field of my entire library with information that I do not wish to mention and that appears when exporting bibliographies.
Is there a way to delete the information in the extra field of all references in the library without modifying each reference individually (it contains 3,200 documents and this would take a very long time...)
Thank you for your help !
A plug-in has filled the ‘extra’ field of my entire library with information that I do not wish to mention and that appears when exporting bibliographies.
Is there a way to delete the information in the extra field of all references in the library without modifying each reference individually (it contains 3,200 documents and this would take a very long time...)
Thank you for your help !
Upgrade Storage
Once your data is securely backed up, you can follow these steps to clear the value of the "extra" field in all selected items:
1. Select the items you’d like to modify (use Cmd/Ctrl+A in the root of your library to select all).
2. From the menu bar, choose Tools → Developer → Run JavaScript.
3. Tick "Run as async function"
4. Paste the following code:
let clearExtra = async (i) => {
if (i.isRegularItem()) {
i.setField("extra", "");
await i.saveTx();
}
};
await Promise.all(
ZoteroPane.getSelectedItems().map(i => clearExtra(i))
);
5. Press Run.
(I've edited the code few minutes after posting initially to make sure it correctly waits for the changes to execute)
The following script will remove ALL book authors from EVERY SELECTED book section item. Same instructions as before (Run as async function).
Before applying, please see my warning about scripting and backup from the original message.
let bookSectionID = Zotero.ItemTypes.getID("bookSection");
let bookAuthorID = Zotero.CreatorTypes.getID("bookAuthor");
let clearBookAuthors = async (i) => {
if (i.itemTypeID !== bookSectionID) {
return;
}
let creators = i.getCreators().filter(c => c.creatorTypeID !== bookAuthorID);
if (creators.length === i.numCreators()) {
return;
}
i.setCreators(creators);
await i.saveTx();
};
await Promise.all(
ZoteroPane.getSelectedItems().map(i => clearBookAuthors(i))
);
https://s3.amazonaws.com/zotero.org/images/forums/u7424907/5it537hvvnaob73m1bpg.png