Reinstating Short Titles

I deleted all the short titles from my entries as I thought they were interfering with the formatting that I needed. I now need those short titles for the referencing system that I am using. Is there a way to automatically reinstate short titles after they have been removed?
  • Tools -> Developer -> Run JavaScript, paste the following:

    for (let item of ZoteroPane.getSelectedItems()) {
    if (!item.isRegularItem()) continue;
    let title = item.getField("title", false, true);

    let setShortTitle = false;
    // shorten to before first colon
    let index = title.indexOf(":");
    if (index !== -1) {
    title = title.substr(0, index);
    setShortTitle = true;
    }
    // shorten to after first question mark
    index = title.indexOf("?");
    if (index !== -1) {
    index++;
    if (index != title.length) {
    title = title.substr(0, index);
    setShortTitle = true;
    }
    }

    if (setShortTitle) {
    item.setField("shortTitle", title);
    await item.saveTx();
    }
    }


    When you click Run, it will set automatic short titles on all selected items.
  • Thank you for your response. When I run the copied text the return value comes up as: ===>undefined<=== (undefined)

    Am I doing something wrong?
  • I am working on a Mac
  • No, that’s normal. Did the selected items’ Short Title fields change?
  • Yes! it just took a while. Thank you soooooo much - this is magic!
Sign In or Register to comment.