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?
  • There's no built-in way to do this at the moment, but there are some examples here of running a script to modify multiple fields:

    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.
  • though I don't know if what it's saving should be considered incorrect in general.
    I'd say so, yes. The date is in the date field and the edition should go in the edition field, so we could try to clean this up on import.

    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)
  • Following up on this - I've tried to fix this issue using both Zutilo and Javascript, but so far, no luck.

    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";
  • You have curly/typographic quotes around "Pittsburgh Courier" -- never write code in a Word processor.
    Once you fix those, it runs.
Sign In or Register to comment.