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

Is there a way to capitalize a string using batch rename regex in Bridge?

Enthusiast ,
Oct 30, 2014 Oct 30, 2014

Copy link to clipboard

Copied

Has anyone had success using more advanced pieces of regex to properly rename strings? I want to Capitalize the 3rd back reference in a file name, and although I believe I'm following the proper way of doing so via Replacement Text Case Conversion, Bridge is just giving me a capital U instead. Please see what I am doing below. Additionally, does anyone know what flavor regex Bridge uses? Thanks!
Screen Shot 2014-10-30 at 11.18.58 AM.png

TOPICS
Scripting

Views

1.7K

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
Community Expert ,
Nov 21, 2017 Nov 21, 2017

Copy link to clipboard

Copied

Just stumbled over this old post…

Bridge appears to use regex more for the search, the replace is limited and back-references to capture groups such as $U1 or U$1 don’t work to change case.

A hint can be found here:

Renaming images in bridge

I found a “solution” which works for two words separated by a space, however it is not pretty and if there are more words, then it would require more work. This is needlessly complicated, however it is what I came up with (I would hope that there are more elegant and robust methods than this).

case.png

If this could be scripted (rather than use Batch Rename), then it would be much easier to run a script that used a very simple JavaScript based regex to find (\b\w) however it all relies on the uppercase replacement being accepted, which I am not sure about… Of course, if Adobe simply offered a Title Case option in addition to the other case options, then we would not have to try so hard to work around these shortcomings in the software.

Votes

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
Community Expert ,
Dec 02, 2017 Dec 02, 2017

Copy link to clipboard

Copied

I tried hacking the following script posted by SuperMerlin to use an uppercase replace, without any success, however that is most likely due to my lack of knowledge of JavaScript (I do have some limited knowledge of Regular Expressions):

Re: Remove extension with Batch Rename

The regex find used variations such as:

(\b[a-z])

\b[a-z]

\b\w

However the tricky bit is the replace, not the find…

Votes

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
Enthusiast ,
Dec 02, 2017 Dec 02, 2017

Copy link to clipboard

Copied

Thanks for this. The scripting route is a good suggestion, and I do have some extendscripts in my pipeline that I could modify the file name at that juncture, but it would be great if this were supported with bridge to keep things consistent.

Votes

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
Guide ,
Dec 03, 2017 Dec 03, 2017

Copy link to clipboard

Copied

LATEST

As one example to do the uppercase.

var test = File ("/c/folder/folder/test_testing_name_01.jpg");

var EXT = test.name.toLowerCase().match(/[^\.]+$/);

var Name = test.name.replace(/\.[^\.]+$/, '');

var parts = Name.split("_");

parts[2] = parts[2].charAt(0).toUpperCase() + parts[2].substr(1).toLowerCase();

alert(parts.join("_") +"." +EXT);

or

var test = File ("/c/folder/folder/test_testing_name_01.jpg");

var bits = decodeURI(test.name).match(/(.+)_(.+)_(.+)_(.+)/);

bits[3] = bits[3].charAt(0).toUpperCase() + bits[3].substr(1).toLowerCase();

bits.shift();

alert(bits.join("_"));

Votes

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
Community Expert ,
Nov 21, 2017 Nov 21, 2017

Copy link to clipboard

Copied

For what it is worth, here is an example, changing testing_testing_hello_01.txt to testing_testing_Hello_01.txt

caps.png

Votes

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