How to batch edit title case into sentence case for multiple items in Zotero
Zotero users might use APA 7th for their reference. There is a problem when the metadata in Zotero is title case, it is laborious to change it every time to sentence case. I found a java script that can take care of all items at once.
Usage:
copy the code below
Zotero-Tools-Developer-Run JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14
zoteroPane = Zotero.getActiveZoteroPane(); items = zoteroPane.getSelectedItems(); var result = ""; for (item of items) { var title = item.getField('title'); result += " " + title + "\n"; var new_title = title.replace(/\b([A-Z][a-z0-9]+|A)\b/g, function (x) { return x.toLowerCase(); }); new_title = new_title.replace(/(^|\?\s*)[a-z]/, function (x) { return x.toUpperCase(); }); result += "-> " + new_title + "\n\n"; // // Do it at your own risk item.setField('title', new_title); await item.saveTx(); } return result;
The only issue is that it can’t uppercase the first letter after the “:” there is still minimum work to be done, but I am not an expert in Java so if you find a better way, just let me know.
If you want all title case, you can try another script below: