Bridge: Add a "find and replace" function for quick caption corrections.

  • 2
  • Idea
  • Updated 5 months ago
  • (Edited)
Add a "find and replace" function to Bridge so that if you spot a spelling mistake in 200 image captions they don't need to be altered one by one.
Photo of PAUL HAYWARD

PAUL HAYWARD

  • 4 Posts
  • 1 Reply Like

Posted 5 years ago

  • 2
Photo of Rick Burress

Rick Burress

  • 102 Posts
  • 15 Reply Likes
I believe this can already be done with the standard find, then the batch rename command.
Am I wrong?
When you say in "image captions" this could be done with "replace metadata" or "append metadata" command in tools, no?
Photo of PAUL HAYWARD

PAUL HAYWARD

  • 4 Posts
  • 1 Reply Like
Hi Rick,

Here's a specific example of the problem:

200 images each with a unique caption in the "description" metadata field. Every caption contains a word which is spelt incorrectly but this word occurs at a different point in the caption each time.

I want to find and replace the incorrectly spelt word only for all images in a single action in the same way that "find and replace" works in Word or similar software.

Batch rename allows for a "string substitution" but this only affects the filename.
Append metadata allows you to add to a caption, replace metadata replaces all caption info.

I hope I'm missing something.
Photo of Paul Riggott

Paul Riggott

  • 359 Posts
  • 143 Reply Likes
All you need to do is write a javascript to do it.
Photo of Casey Flanigan

Casey Flanigan

  • 6 Posts
  • 0 Reply Likes
so paul... this was working great. but now i get this error message.. any ideas?
Photo of Rick Burress

Rick Burress

  • 102 Posts
  • 15 Reply Likes
Thanks for the specifics, Paul Hayward.
I believe you have stumped me.

Paul Riggott's just "write a javascript" made me laugh.
Like we all have that skill.

:-)

Paul R., will you write it for us?

r.
Photo of Paul Riggott

Paul Riggott

  • 359 Posts
  • 143 Reply Likes
I will see if I have time and will put one together for you.
Photo of PAUL HAYWARD

PAUL HAYWARD

  • 4 Posts
  • 1 Reply Like
Thankyou Paul! Much appreciated.
Photo of Paul Riggott

Paul Riggott

  • 359 Posts
  • 143 Reply Likes
Hi Rick and Paul.

Download the script from:-
www.ps-bridge-scripts.talktalk.net/do...

To install unzip and place this script into the following folder:
Start Bridge
Preferences -Startup Scripts
At the bottom click the "Reveal Button" this will open the folder where the script should be placed.
Close and restart Bridge.
Accept the new script.

To use:-
Select the documents you want to target.
Tools - Find and Replace.

The "Replace" field is where you enter what you want to find
The "With" field is where you enter what you want it to Replace.
N.B. If the "With" field is left blank the characters will be removed.
The Global checkbox will let you replace more than one occurrence in the Description

Hope you find it of use.
Photo of Paul Riggott

Paul Riggott

  • 359 Posts
  • 143 Reply Likes
Mike, have you done a refresh of the cache for those documents?
Photo of Mikekemp

Mikekemp

  • 11 Posts
  • 0 Reply Likes
Ah, that works. You don't seem to have to do that on the tifs or jpegs. For whatever reason... Thanks!
Photo of Paul Riggott

Paul Riggott

  • 359 Posts
  • 143 Reply Likes
I have now added a refresh on the selected files, so the changes should now show after running the script Mike.
Photo of Mikekemp

Mikekemp

  • 11 Posts
  • 0 Reply Likes
I just downloaded and tested it and I have to purge the cache after running the find and replace tool, but that's totally fine, it's an easy step. Cheers Paul.
Photo of PECourtejoie

PECourtejoie, Champion

  • 792 Posts
  • 283 Reply Likes
Mike or Paul  could you post the file on ps-scripts.com so that others could use this very useful script ? 
Photo of PAUL HAYWARD

PAUL HAYWARD

  • 4 Posts
  • 1 Reply Like
Paul, this is fantastic, exactly what I needed! Thankyou so much.
Photo of Rick Burress

Rick Burress

  • 102 Posts
  • 15 Reply Likes
Paul Riggott for President!
Thank you, Paul.
Photo of Adam Stevens

Adam Stevens

  • 1 Post
  • 0 Reply Likes
Hi Paul,
Your script is brilliant, thanks for sharing it on this forum! In theory is the same thing possible to amend keywords?
Adam
Photo of PECourtejoie

PECourtejoie, Champion

  • 792 Posts
  • 285 Reply Likes
Photoshop and many other Adobe programs does also have a spellchecker and find/replace feature, it would be useful if they were implemented in Bridge.

Thanks, Paul for your contribution of something that we should have in Default!
Photo of Charles Uebele

Charles Uebele

  • 16 Posts
  • 2 Reply Likes
I agree, being a horrible speller, this should be in Bridge!!! I also agree that Paul has been a huge asset to the Adobe community, and we miss now miss that!
Photo of PECourtejoie

PECourtejoie, Champion

  • 792 Posts
  • 285 Reply Likes
Photo of Casey Flanigan

Casey Flanigan

  • 6 Posts
  • 0 Reply Likes
so.. this was working great
but then, now not so much!
Photo of Casey Flanigan

Casey Flanigan

  • 6 Posts
  • 0 Reply Likes
Photo of Paul Riggott

Paul Riggott

  • 359 Posts
  • 143 Reply Likes
You need to copy the script again, as your error is showing HTML errors and the script does not have any HTML in at all.
Photo of Casey Flanigan

Casey Flanigan

  • 6 Posts
  • 0 Reply Likes
Photo of Casey Flanigan

Casey Flanigan

  • 6 Posts
  • 0 Reply Likes
now this error, i know we are so close!
Photo of Paul Riggott

Paul Riggott

  • 359 Posts
  • 143 Reply Likes
Same problem.
Goto the link then click "RAW"

Once you get the new page Right Click and save as text file, it should save in the correct format .jsx
Hope this works for you.
Photo of Casey Flanigan

Casey Flanigan

  • 6 Posts
  • 0 Reply Likes
it worked! thank you thank you!
this script is invaluable to me! thank you!
Photo of Brian Fiskar

Brian Fiskar

  • 12 Posts
  • 0 Reply Likes
Anyone here can modify this script to work on Headlines and Keywords?
Photo of Kukurykus

Kukurykus

  • 90 Posts
  • 15 Reply Likes
In Paul Riggott script you are linked in 8th post of this theard change lines 66 - 75 to:

    for(i = 0; i < (arr = ['description', 'Headline', 'Keywords']).length; i++) {
      md.namespace = i ? 'http://ns.adobe.com/photoshop/1.0/' :
      'http://purl.org/dc/elements/1.1/'; Caption = eval('md.' + arr[i])

        if (!Caption.length) continue;
        if (patt.test(Caption = Caption.toString())) {
          newCaption = Caption.replace(patt, win.g610.et1.text.toString())
          if (win.g620.cb3.value) newCaption = newCaption.replace(/["'\(\)]/g, '')
          function cap(v) {!i ? md.description = v : (i < 2 ? md.Headline = v : md.Keywords = v)}
          cap(''), cap(newCaption)
      }
    }
Photo of Paul Riggott

Paul Riggott

  • 343 Posts
  • 130 Reply Likes
Thanks Kukurkus if anyone wants to change the code they can do. I like to keep it simple so a novice can add/amend to thier own needs.
Photo of Kukurykus

Kukurykus

  • 90 Posts
  • 15 Reply Likes
I came too late with my script :) I wrote it right after Brian Fiskar request - but went to sleep without testing. When I visitied this forum again I noticed you replied one hour earlier, but since tests didn't fail I eventually posted my vers. as well. Cerntainly everything is based on your many years work :D
(Edited)
Photo of Paul Riggott

Paul Riggott

  • 359 Posts
  • 143 Reply Likes
Hi Brian,  I have modified the script and it now will support:
Description, Headline, Title and Keywords
It can be downloaded from:-
http://www.ps-bridge-scripts.talktalk.net/download/Find%20and%20Replace.zip

P.S.
Don't forget to remove the old version!
(Edited)
Photo of Brian Fiskar

Brian Fiskar

  • 12 Posts
  • 0 Reply Likes
There are two small problems that could be related.
1. The menu is blank unless I put the Cursor on the selection. Then it appears in the slot.
2. After the function run the field in the IPTC appears to be empty like everything was erased. No, it wasn't . After closing and restarting Bridge everything that was there before is there with the change (searched and replaced) of course.
Thanks.
Photo of Paul Riggott

Paul Riggott

  • 343 Posts
  • 130 Reply Likes
Hi Brian can you download the script again, it seems that it was CS6 that had a problem, this has now been fixed.
Photo of Kukurykus

Kukurykus

  • 90 Posts
  • 15 Reply Likes
It seems Paul Riggott already did great job again, but answering to your question I already posted a code 8 posts higher that you put in previous version of script (link to is in this theard)
(Edited)
Photo of Brian Fiskar

Brian Fiskar

  • 12 Posts
  • 0 Reply Likes
Kukurykus, I saw the code but I have no idea what to do with it. Paul, has it in downloadable link. But thank you for trying.
Photo of Brian Fiskar

Brian Fiskar

  • 12 Posts
  • 0 Reply Likes
To Paul,
It has more fields but the same problem still there. I am attaching the screen shot. As you can see fields are empty. If I click on the arrow down each field appears in the highlight but not all at once. 2 pictures attached. Thanks.
(Edited)
Photo of Kukurykus

Kukurykus

  • 90 Posts
  • 15 Reply Likes
I already wrote in that post where you see code what to do, I'm quoting:
In Paul Riggott script you are linked in 8th post of this theard change lines 66 - 75 to:
Then I posted a code, you should copy and do what is said in that sentence. If you still don't know where to download that script, however I said it's in 8th post of this theard here you have a link:

http://www.ps-bridge-scripts.talktalk.net/download/Find%20Replace%20In%20Description.zip

To make it easier for you (as I assume you use notepad where lines are with no numbers) I post here also exact part you should replace to that you're finding in my original post:

md.namespace =  "http://purl.org/dc/elements/1.1/";
var Caption = md.description ? md.description[0] : "";
if(Caption == "") continue;
var result=patt.test(Caption.toString());
if(result == true){
  var newCaption = Caption.replace(patt,win.g610.et1.text.toString());
  if(win.g620.cb3.value)  newCaption = newCaption.replace(/["'\(\)]/g, "");
  md.description='';
  md.description = newCaption;
}

If you still don't know how to use it let me know ;)
(Edited)
Photo of Paul Riggott

Paul Riggott

  • 359 Posts
  • 143 Reply Likes
In that case please remove lines 7 to 12
///////////////////////
var ver = app.version.match(/^\d/);
if (ver != 5){
g = win.graphics;
var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [0.99, 0.99, 0.99, 1]);
g.backgroundColor = myBrush;
}
////////////////////////////
As some versions do not like setting the color. This should fix the problem.
Photo of Brian Fiskar

Brian Fiskar

  • 12 Posts
  • 0 Reply Likes
I did but it did not help. I removed the lines using the notepad. Restarted the Bridge but did not help.
Edit: Actually that is not what happened. What happened is that Bridge did not load the new script. It came up with an error saying that "too many braces" and something about line 176.
Another edit: It is all good now. I did not remove line 12. 7-12 is 6 lines, not 5. Thank you again!!!!
(Edited)
Photo of Brian Fiskar

Brian Fiskar

  • 12 Posts
  • 0 Reply Likes
Ok. So the first problem is fixed. But the second problem is still there. I think it only happens when there are "multiple values" in the same field if many photos are selected. After running Find and Replace script the field completely disappears. I need to restart the Bridge to get it back. Take a look, Description field is gone.
(Edited)
Photo of Paul Riggott

Paul Riggott

  • 359 Posts
  • 143 Reply Likes
Have you tried to do a "Purge cache for selection" as sometimes the cache does not get updated for some reason.
Photo of Brian Fiskar

Brian Fiskar

  • 12 Posts
  • 0 Reply Likes
Nope, I don't know where it is. Under "Cache" I have options "Compact Cache Now" and "Purge all cache now" but not "Purge cache for selection".
Photo of Paul Riggott

Paul Riggott

  • 359 Posts
  • 143 Reply Likes
Ah, that is in the Context menu (Right Mouse Click)
Photo of Paul Riggott

Paul Riggott

  • 359 Posts
  • 143 Reply Likes
I have added a couple more fields...