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!
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:
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).
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.
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…
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.
Copy link to clipboard
Copied
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("_"));
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