Batch edit Title Case for all entries

Hello,
I've read through the forums and I've seen that batch editing whole libraries with something like - Select All - Transform Text - Title Case - has been requested for years.
Any progress on this?
Simply because I want my bibliography to be consistent.
Cheers
Scott
  • Nothing new, no. But you really want to store titles in sentence case, not in title case. A whole range of citation styles is not going to be correct otherwise (see https://www.zotero.org/support/kb/sentence_casing )
  • Would it be better to have all translators store items only in sentence case? Obviously, the citation style will convert to title case if a citation requires that.
  • It's a tricky question. Where items are displayed in title case in the metadata (as is the case for many journal publishers, e.g.) we'd have to force sentence case on import, which carries the exact same automation problems as doing so for citations. Aurimas always made the case that we should still do it (and have people fix proper nouns as needed), but we've never come to a decision. The downside is that people will complain about forced lowercase on proper nouns, which looks quite wrong in the database, even if it makes no difference for title cased citations.

    I'm honestly not sure what's better.
  • I understand that. What about converting only dictionary words to sentence case, and leave out any word that is all caps or has numbers or not a dictionary word as-is?
  • edited February 2, 2017
    Forcing lower case in translators would make more work. I speak from experience as I use Zotero primarily as an importer, editor, and MODS generator and process almost 1800 titles each day. "Fixing" proper nouns requires thought and effort.

    Some English language publishers journal article titles are in sentence case with proper casing of proper nouns. These titles require no editing.

    Of the many publishers that insist on title case, many (most?) titles do not contain proper nouns and do not require editing after conversion. Where proper nouns exist they can be noticed, remembered and quickly changed to UC after manual title conversion.

    I usually leave non-English language titles mostly as-is because I'm seldem certain of the correct casing rules. Converted non-English titles would require very careful editing using the original source to be certain that character case matched. This would be doubly tedious for characters with diacritics or decorations. How would this auto-conversion work for non Latin characters?

    While it might be possible to use the language tag as a cue to assist the automated case operation, several major publishers do not provide metadata that includes a language spec.



  • Since that's still going to have problems, I think if we're going to do this, we should go for a clean, easy-to-follow solution. @Rintze @dstillman do you have any opinion on this.
  • @DWL-SDCA good points all. We would do this on a by-translator basis and a) don't do it for databases that use mostly sentence case b) don't do it for sites that have large non-English content c) check for language tags d) exempt all non-Latin characters.
    We could also check if the title is already in title case before converting. Still, non-English titles are a major concern and we don't want to get them wrong much.
  • I'm not a fan of automatic case conversion on import, since it's probably quite unreliable and because it makes it hard to distinguish items imported directly in sentence case (which most likely have correct casing) from items imported in title case but automatically converted to sentence case (which would need manual review). It also hides the real problem, which is that publishers shouldn't make item metadata available in title case.

    By the way, maybe it would make sense to move the "Title Case" and "Sentence case" options out of the "Transform Text" right-click menu and bring them to the top level (and rename them to e.g. "Convert to Title Case" and "Convert to Sentence case"? That would make it easier to use them for manual corrections.
  • For what it is worth, even database specific translators cannot always get this right because databases aren't consistent . My recommendation is to keep things as they are.

    New PubMed records (in-process) are provided mostly as-is from the publisher. That often means title case and sometimes even all-caps. Those records that are from Medline indexed journals will rather quickly have their titles concerted to sentence case. Articles from non-Medline journals are eventually converted to sentence case but not necessarily in good time. Pre-1965 records many times remain all-caps.

    Web of Science record titles are intentionally modified with with punctuation and case alterations as protection against wholesale copying.

    While I agree with the Zotero goal to minimize the need for editing imported records. I hope that Zotero users will (at least for the items they cite) will take time to be sure that their Zotero records are correct for their purpose. Some editing is surely inevitable.




  • I definitely think titles imported in Title Case should be kept as is. As citation errors go, accidental title case is much less jarring than proper nouns or acronyms being lower case. Assuming there will always be a substantial user base who does no corrections, leaving title case is preferable.

    For titles imported in all caps, I think converting to title case is probably okay. The only thing this breaks is acronyms, but I think those are probably uncommon enough to make fixing the very jarring all caps more preferable.
  • OK, I'm convinced on leaving import as is. Thanks.
    For titles imported in all caps, I think converting to title case is probably okay. The only thing this breaks is acronyms, but I think those are probably uncommon enough to make fixing the very jarring all caps more preferable.
    FWIW, we do this on a case-by-case basis in a fairly large number of translators and have not once gotten a complaint.
  • Yeah, that's what I thought
  • That was a nice discussion.

    Here's an alternate approach based on the assumption that for most users it is a small subset of "words" that need to be a certain way in the title. This could include chemical names with super-/sub-scripts.

    So, could a user create a dictionary and if any word in the title matches an entry in the dictionary, then that word will be swapped with the word as it appears in the dictionary. No need to change casing at download. But maybe create an option in the same menu as the Change to Title/Sentence Case that says "Search/Replace from my dictionary". If such a feature could be implemented, I can see myself manually converting the errant titles first to sentence case followed by a search/replace function. That way, I can "fix" almost all titles in two steps. For my own use case, I think there are only about 50-100 words that need to be in my dictionary.
  • Rather than having Zotero do this automatically in import, or to all entries in an entire library, how about allowing the selection of multiple documents (as usual), and having a command that does the transform to all selected documents?
  • I would definitely hope that when the long-awaited batch-edit functionality arrives, it'd include the ability to batch-apply (pseudo) sentence case, yes.
  • I have modified a javascript based on the code from others in another link, I forgot from whom, but big thanks!

    zoteroPane = Zotero.getActiveZoteroPane();
    items = zoteroPane.getSelectedItems();
    var result = "";

    for (item of items) {
    var extra = item.getField('extra');

    // Check if the title has not been processed before
    if (extra.indexOf("sentenceCase:1") === -1) {
    var title = item.getField('title').trim();

    if (title) {
    result += " " + title + "\n";

    // Make first char uppercase and the remainder lowercase
    var new_title = title[0].toUpperCase() + title.substring(1).toLowerCase();

    // Capitalize the first letter after ':' or '?'
    new_title = new_title.replace(/([:?])\s*(.)/g, function(match, p1, p2) {
    return p1 + ' ' + p2.toUpperCase();
    });

    result += "-> " + new_title + "\n\n";

    // Add marker in extra to stop title being overwritten by this code
    var new_extra = extra + "\nsentenceCase:1";

    // Uncommented this to write changes to title and extra fields
    item.setField('title', new_title);
    await item.saveTx();
    item.setField('extra', new_extra);
    await item.saveTx();
    }
    }
    }

    return result;


    you need to ctrl A all the files you want, and then go to tools-developers-runjavasccript, then paste the code. This code has to keep the capital of the first letter after "?" or ":", but for other words that need to keep capital, like "SMEs" and such, please welcome others to expand the word list. This is code is modified base on OpenAI ChatGPT, it really works
Sign In or Register to comment.