Script to Batch Rename as Title Case
This comes up from time to time due to the shortcoming of Bridge Batch Renaming having only UPPERCASE or lowercase options. It is possible to create a Regular Expression based Batch Rename to create Title Case , however, it isn't very flexible and can be complex to setup.
The following script simplifies the process of renaming selected files to use a simple Title Case naming convention.
For example, the following original filenames:
the quick brown fox jumps over the lazy dog.psd
THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.psd
Would be transformed to:
The Quick Brown Fox Jumps Over The Lazy Dog.psd
/*
Rename to Title Case.jsx
v1.0 - 26th December 2023, Stephen Marsh
https://community.adobe.com/t5/bridge-discussions/script-to-batch-rename-as-title-case/td-p/14319096
*/
#target bridge
if (BridgeTalk.appName == "bridge") {
var titleCase = new MenuElement("command", "Rename to Title Case v1.0", "at the end of Tools");
}
titleCase.onSelect = function () {
var theFiles = app.document.selections;
for (var a = 0; a < theFiles.length; a++) {
// Add the PreservedFileName metadata
var selectedFile = theFiles[a].spec;
var theMD = new Thumbnail(selectedFile).synchronousMetadata;
theMD.namespace = "http://ns.adobe.com/xap/1.0/mm/";
var theName = decodeURI(selectedFile.name).replace(/\.[^\.]+$/, '');
theMD.PreservedFileName = theName;
// Rename the file to Title Case
var selsName = decodeURI(app.document.selections[a].spec.name.replace(/\.[^\.]+$/, ''));
var selsExt = decodeURI(app.document.selections[a].spec.name.replace(/(^.+)(\.[^\.]+$)/, '$2'));
app.document.selections[a].name = toTitleCase(selsName) + selsExt;
}
function toTitleCase(theText) {
var words = theText.toLowerCase().split(' ');
for (var i = 0; i < words.length; i++) {
words[i] = words[i].charAt(0).toUpperCase() + words[i].slice(1);
}
return words.join(' ');
}
}
https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

