Search and replace?
Hi,
I have over 2200 articles in my library, and some of them have problems in some tags.
E.g. the latest tag I was correcting, was the abbreviation from the Journal of Physiology being 'J Phys (Lond.)' and I was removing the '(Lond.)' from it.
Would it be possible to somehow tell Zotero to change all the Journal abbreviations that have 'J Phys (Lond.)' to 'J Phys' ?
Thank you
I have over 2200 articles in my library, and some of them have problems in some tags.
E.g. the latest tag I was correcting, was the abbreviation from the Journal of Physiology being 'J Phys (Lond.)' and I was removing the '(Lond.)' from it.
Would it be possible to somehow tell Zotero to change all the Journal abbreviations that have 'J Phys (Lond.)' to 'J Phys' ?
Thank you
This is an old discussion that has not been active in a long time. Before commenting here, you should strongly consider starting a new discussion instead. If you think the content of this discussion is still relevant, you can link to it from your new discussion.
Upgrade Storage
Assuming you mean the latter, first make a backup of zotero.sqlite in your Zotero data directory with Zotero closed and then go to Tools → Developer → Run JavaScript and run this code:
var fieldName = "journalAbbreviation";
var oldValue = "J Phys (Lond.)";
var newValue = "J Phys";
var fieldID = Zotero.ItemFields.getID(fieldName);
var s = new Zotero.Search();
s.libraryID = Zotero.Libraries.userLibraryID;
s.addCondition(fieldName, 'is', oldValue);
var ids = await s.search();
if (!ids.length) {
return "No items found";
}
await Zotero.DB.executeTransaction(async function () {
for (let id of ids) {
let item = await Zotero.Items.getAsync(id);
let mappedFieldID = Zotero.ItemFields.getFieldIDFromTypeAndBase(item.itemTypeID, fieldName);
item.setField(mappedFieldID ? mappedFieldID : fieldID, newValue);
await item.save();
}
});
return ids.length + " item(s) updated";