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!
  • Hi. I was wondering if you could also give me the script for deleting all the short titles as I am now needing to do this for a different article.
  • Why would you want that? If you don't want short titles, change the citation style; don't delete them in the data
  • I need it with the same citation style, but they only want short titles for cases not articles.
  • Is it possible do you think?
  • Then you edit the citation style to only print short titles for the specific item types you want.
  • Are you able to help me with that? I'm not versed in html language unfortunately ... and if I edit the style can I revert back to the original or does it save as a new (edited) style? Thanks for your help
  • edited June 6, 2024
    I do not know which citation style you are using nor for which item type you'd need this.
    (copy/pasting the same reply in different threads doesn't help your case. Please be respectful of our forum etiquette)
  • I accidentally placed the reply in the wrong thread as I had another question about the bibliography not using italics, but then thought I deleted it. Apologies for that. I am using AGLC and want only cases to have the short title.
  • I'm not entirely sure still what exactly you want to achieve.
    Assuming that for the full notes of cases you want to print the short title instead of the long title.
    You'd change the "title" macro from:
    <macro name="title">
    <choose>
    <if type="book legislation motion_picture manuscript report" match="any">
    <text variable="title" font-style="italic" text-case="title"/>
    </if>
    <else-if type="bill">
    <text variable="title" text-case="title"/>
    </else-if>
    <else-if type="legal_case">
    <text variable="title" font-style="italic" strip-periods="true"/>
    </else-if>
    <else-if type="entry-dictionary">
    <text variable="container-title" font-style="italic"/>
    </else-if>
    <else-if type="entry-encyclopedia">
    <group delimiter=", ">
    <text variable="publisher"/>
    <text variable="container-title" font-style="italic"/>
    </group>
    </else-if>
    <else>
    <text variable="title" quotes="true" text-case="title"/>
    </else>
    </choose>
    </macro>


    to
    <macro name="title">
    <choose>
    <if type="book legislation motion_picture manuscript report" match="any">
    <text variable="title" font-style="italic" text-case="title"/>
    </if>
    <else-if type="bill">
    <text variable="title" text-case="title"/>
    </else-if>
    <else-if type="legal_case">
    <text variable="title" font-style="italic" strip-periods="true" form="short"/>
    </else-if>
    <else-if type="entry-dictionary">
    <text variable="container-title" font-style="italic"/>
    </else-if>
    <else-if type="entry-encyclopedia">
    <group delimiter=", ">
    <text variable="publisher"/>
    <text variable="container-title" font-style="italic"/>
    </group>
    </else-if>
    <else>
    <text variable="title" quotes="true" text-case="title"/>
    </else>
    </choose>
    </macro>


    Follow this guide to the T!! and change the ID and self link as explained. Otherwise your style will be overwritten.
    https://www.zotero.org/support/dev/citation_styles/style_editing_step-by-step
  • Thanks so much, appreciate your time. It is mostly about not having short titles for every other type of reference. I am happy to manually add short titles to cases, if need be, but would like to be able to have a version of AGLC that does not put the short titles in brackets after every reference that is cited that has a colon in the title.
Sign In or Register to comment.