editing metadata (current and future)
Apologies if this is covered in the documentation.
I'm pulling some newspaper articles into Zotero, and the Publication field in the metadata is nonstandard. It reads: The Pittsburgh Courier (1955-1966), City Edition
For a standard Chicago footnote, I'll only want the name of the publication (ie, Pittsburgh Courier). Is there a way of 1) editing multiple records in bulk, and 2) telling Zotero to override the publication name & replace it with my preferred format for future imports?
I'm pulling some newspaper articles into Zotero, and the Publication field in the metadata is nonstandard. It reads: The Pittsburgh Courier (1955-1966), City Edition
For a standard Chicago footnote, I'll only want the name of the publication (ie, Pittsburgh Courier). Is there a way of 1) editing multiple records in bulk, and 2) telling Zotero to override the publication name & replace it with my preferred format for future imports?
https://www.zotero.org/support/dev/client_coding/javascript_api#batch_editing
As for the field, if you say where you're saving from we could take a look, though I don't know if what it's saving should be considered incorrect in general.
For batch editing something this simple, Zutilo would also be a viable option (just overwriting a single field with a single value is fairly straightforward and doesn't require any scripting)
With Zutilo, I can't see that there's an option to copy a single field and overwrite that same field in other items - only "All Item Fields" (or am I missing something?)
With Javascript, I tried using the code below (adapted from the link above), but it just gives me "SyntaxError: illegal character"
Any advice?
var fieldName = "publicationTitle";
var oldValue = "Pittsburgh Courier (1955-1966), City Edition";
var newValue = “Pittsburgh Courier”;
var fieldID = Zotero.ItemFields.getID(fieldName);
var s = new Zotero.Search();
s.libraryID = ZoteroPane.getSelectedLibraryID();
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";
Once you fix those, it runs.