Author Topic: find and replace caption string with various non sequential numbers within  (Read 189 times)

Offline jmar6482

  • Newcomer
  • *
  • Posts: 7
    • View Profile
I have hundreds of images that have this type of text that I want to remove ifrom each caption area of each image. examples: file reference # 16573_054cpc, file reference # 16553_012cpc, file reference # 16330_138cpc. Is there a way to find and replace all data after file reference with blank? All of these are at the end of the caption with nothing after it.

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 25426
    • View Profile
    • Camera Bits, Inc.
I have hundreds of images that have this type of text that I want to remove ifrom each caption area of each image. examples: file reference # 16573_054cpc, file reference # 16553_012cpc, file reference # 16330_138cpc. Is there a way to find and replace all data after file reference with blank? All of these are at the end of the caption with nothing after it.

If I understand you correctly, you have filenames that look like this:
file reference # 16573_054cpc.ext
file reference # 16553_012cpc.ext
file reference # 16330_138cpc.ext

...where 'ext' is something like JPG or NEF, etc.

And you want the result to be:
file reference # 16573.ext
file reference # 16553.ext
file reference # 16330.ext

Is that correct?  Or some other result?

-Kirk

Offline jmar6482

  • Newcomer
  • *
  • Posts: 7
    • View Profile
The filenames were copied into the caption area at some point long ago. So I am dealing only with the filenames that are in captions, nowhere else. They are all unique so  "find and replace" needs to ignore the actual numbers/alpha characters and replace all with a blank after this : File reference #

This string is all at the end of the caption in each image so need to worry about what comes after as there is nothing after

There are no extensions involved as this is all in caption area only

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 25426
    • View Profile
    • Camera Bits, Inc.
The attached image, when the settings are duplicated on your end, should do what you want.

HTH,

-Kirk

Offline jmar6482

  • Newcomer
  • *
  • Posts: 7
    • View Profile
Hi Thanks. I'm almost there. Your suggestion of using this "_[0-9]+THA" got me from this:

File Reference  # 33595_375THA

to this

File Reference  # 33595

How can I eliminate the characters all the way to the hash tag so I get this:

File Reference  #

Thanks in advance

Online ahoward

  • Camera Bits Staff
  • Uber Member
  • *****
  • Posts: 1140
    • View Profile
You can use the following in your Find field:

" [0-9]+_[0-9]+THA"

Don't use the quotes, but do note the space in front of the [

If you'd like to learn more or practice with other Regular Expressions, checkout: https://regexr.com
ChatGPT or other AI assistant is also pretty good at giving you the right regex to do what you are looking for, but I'd test its suggestions in regexr before making a big change to your images with it.

Offline jmar6482

  • Newcomer
  • *
  • Posts: 7
    • View Profile
That works. Thanks for the help and the link.