• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
2

Script to Batch Rename as Title Case

Community Expert ,
Dec 26, 2023 Dec 26, 2023

Copy link to clipboard

Copied

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", "at the end of Tools");
}

titleCase.onSelect = function () {
   var theFiles = app.document.selectionsLength;
   for (var a = 0; a < theFiles; a++) {
      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 theText = theText.toLowerCase().split(' ');
      for (var i = 0; i < theText.length; i++) {
         theText[i] = theText[i].charAt(0).toUpperCase() + theText[i].slice(1);
      }
      return theText.join(' ');
   }

}

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

 

TOPICS
Scripting

Views

177

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation