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
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
I'm honestly not sure what's better.
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.
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.
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.
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.
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.
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.
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