Author Topic: Code Replacements (or additions) on a string of existing keywords  (Read 8614 times)

Offline jaybee

  • Newcomer
  • *
  • Posts: 11
    • View Profile
Hi,

Running PM 4.6.8 on Win 7 x64 platform.

I'm trying to accomplish multiple replacements of already existing keywords with those from a set defined in a Code Replacements UTF8 tab-delimited text file. I need to take an image with a set of existing keywords and if certain words exist, either replace them or append them with others.  Started testing but not having much joy... So thought I'd ask to see if this is something I can accomplish inside PM (as I realise Code Replacement is meant for live keywording and saving typing etc.)?

Some keywords I'd like to replace and some I'd like to append and keep the original. Let's start with totally replacing.  Here's an example Code Replacement text file:

Code: [Select]
cat BROWN
dog BLACK
bird BLUE
mouse GREY

In Adobe Bridge I've keyworded an image as cat, dog, bird, mouse in the IPTC Keywords field. I've set the Code replacement delimiter to a , comma.  I would expect dog & bird to be replaced as they are surrounded by the comma delimiters.

Upon opening the image in PM I see "catBLACK,  bird, mouse".  I'm sure I'm missing something obvious but...! :)  It's confusing me because cat was ignored (because of the lack of prior delimiter?) and dog was replaced but not with a delimiter after cat & then the replacement process stopped dead.  Ideal outcome would have been "BROWN, BLACK, BLUE, GREY".

On another file I may require the outcome to append some keywords and replace others i.e. "cat, BROWN, BLACK, BLUE, mouse, GREY" etc.

Any way of getting to these outcomes? I'm looking to automate this process so I can open a set of prior keyworded images in PM and the keywords are replaced/appended according to the external Code Replacement file. I can then export the resulting replaced/appended keyword set to Excel etc.


Thanks in advance.... There's probably another way to do this I'm completely missing!

J


Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 24731
    • View Profile
    • Camera Bits, Inc.
Re: Code Replacements (or additions) on a string of existing keywords
« Reply #1 on: December 18, 2014, 09:44:04 AM »
Are you using the IPTC Stationery Pad to run your replacements?  If so, what does your Keywords field look like?

-Kirk

Offline jaybee

  • Newcomer
  • *
  • Posts: 11
    • View Profile
Re: Code Replacements (or additions) on a string of existing keywords
« Reply #2 on: December 19, 2014, 01:08:43 AM »
Are you using the IPTC Stationery Pad to run your replacements?  If so, what does your Keywords field look like?

-Kirk

Hi Kirk,

No, I'm not using the IPTC Stationery Pad because I'm not doing "live input". Am I missing something?

If I select my test image (already keyworded as cat, dog, bird, mouse) and call the IPTC Stationery Pad it's totally blank.

If I select the image and press the small "i" button for the IPTC info dialogue I see "catBLACK,  bird, mouse" in IPTC Keywords

Thanks!

J

Offline Luiz Muzzi

  • Hero Member
  • *****
  • Posts: 704
    • View Profile
    • Luiz Muzzi Photography
Re: Code Replacements (or additions) on a string of existing keywords
« Reply #3 on: December 19, 2014, 02:28:21 AM »
Hi,
The IPTC Stationery Pad does not reflect the metadata that is in that particular photo, for this you have to use the button "i". The stationery pad is what you intend to apply to a particular photo or group of photos.
HTH

-Luiz Muzzi

Offline jaybee

  • Newcomer
  • *
  • Posts: 11
    • View Profile
Re: Code Replacements (or additions) on a string of existing keywords
« Reply #4 on: December 19, 2014, 03:01:28 AM »
Hi,
The IPTC Stationery Pad does not reflect the metadata that is in that particular photo...

-Luiz Muzzi

Hi Luiz,

Yes, that's what made me wonder why Kirk asked me what it said!! 

I'm trying to use code replacements on an existing set of keywords already embedded in an image, not on a live input basis.

(Actually, just thought it might help to say why I want to do this. The images I have already keyworded need slightly different terminology added before I can send them to another library. I could open each one and add/replace the keywords manually or try and automate it and save time. That's what I'm trying to do.)

J
« Last Edit: December 19, 2014, 03:04:55 AM by jaybee »

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 24731
    • View Profile
    • Camera Bits, Inc.
Re: Code Replacements (or additions) on a string of existing keywords
« Reply #5 on: December 19, 2014, 06:54:02 AM »
Perhaps you could tell me with words or with a screen shot (in JPEG format so it shows up in your post) how you get to the point where you get to this point: "catBLACK,  bird, mouse" ?

Thanks,

-Kirk

Offline jaybee

  • Newcomer
  • *
  • Posts: 11
    • View Profile
Re: Code Replacements (or additions) on a string of existing keywords
« Reply #6 on: December 19, 2014, 07:59:51 AM »
Perhaps you could tell me with words or with a screen shot (in JPEG format so it shows up in your post) how you get to the point where you get to this point: "catBLACK,  bird, mouse" ?

Thanks,

-Kirk

Hi Kirk,

Sorry. I thought I was explaining myself well (my first post goes into some detail), let me try again. Here's what I'm trying to do, what I did, and what happened.

What I'm trying to do:


1) I am a stock photographer.
2) I have images that already have keywords in them. They are already keyworded, they are finished items. So when I open these images in PM I see the keywords in IPTC info.
3) I need to place some of my existing keyworded images with a new stock library. They want the images keyworded slightly differently. So for example, where I may have the word "people" the new library would like to see that keyword as "incidental people". Where I may have the word "city" the new library would like to see  that keyword as "urban view" etc. etc.

So my problem is that I have thousands of images, already keyworded, that would need to be revisited manually to change "people" into "incidental people" and "city" into "urban view" (actually I want to keep words like "city" and ADD "urban view" but let's pretend I just want direct replacements for now.

I want to automate this replacement process and I thought Code Replacements in PM could do it.....

Here's what I did:

1) I keyworded a test image (subject matter doesn't matter, it's a test image) with the keywords  cat, dog, bird, mouse. So the test image has four keywords in the IPTC Keywords field.
2) I set up a Code Replacements text file based on my test image to see if I could automatically replace cat, dog, bird, mouse with other words. Here's how the tab-delimited text file looks:

Code: [Select]
cat BROWN
dog BLACK
bird BLUE
mouse GREY

3) From the above you'll see that where I have a keyword of cat I want to see BROWN replace it, and where I have a keyword of dog I want to see BLACK replace it etc.  Again *this is just a test!!* these words are chosen at random to test if Code Replacements can do this automatically.

What happened:

1) I opened PM and in Edit / Settings / Set Code Replacements I added the path to my saved tab-delimited text file.
2) I navigated to the folder on my HDD where I have my test image (the one keyworded as cat, dog, bird, mouse) and it showed as a thumbnail in PM
3) I selcted it
4) I pressed the "i" in the bottom left hand corner to get to the IPTC info dialogue
5) I look at the IPTC Keywords panel expecting to see the words from the Code Replacement file replace the keywords in the image

6) What I see in the file is "catBLACK,  bird, mouse".  It's clear the Code Replacement file has replaced "dog" with "BLACK" but that's all it's done. That's where I'm at.

I can't explain it clearer than that, sorry.  Ultimate aim is to open PM on a folder full of files which would have certain keywords I specify in a text file replaced automatically via that text file added to Code Replacements.

Does that help?

J







Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 24731
    • View Profile
    • Camera Bits, Inc.
Re: Code Replacements (or additions) on a string of existing keywords
« Reply #7 on: December 19, 2014, 09:21:29 AM »
I think if you were to re-enter your commas in the IPTC Info dialog, the items would be replaced one-by-one.  What you're looking for is more like a Find and Replace option to me.  You can use Find and Replace, but you'd have to do things fairly manually.

The IPTC Stationery Pad is used for automation of this sort of thing, but I don't think there is going to be a good way to do what you are trying to do.  Keywords are a list of distinct items and the commas (or semi-colons) are put there for display purposes.  Normally you'd use something like this to do a bulk replacement:

 /{keywords}/

and you would put that string in some other field, but I think it is going to only replace on the first item in the list (it won't iterate through the list).  Moreover, you'd have to put the expansion in a different field or it may have recursion issues.

I just don't have a solution for you at this time.

-Kirk

Offline jaybee

  • Newcomer
  • *
  • Posts: 11
    • View Profile
Re: Code Replacements (or additions) on a string of existing keywords
« Reply #8 on: December 19, 2014, 10:01:29 AM »
Hi Kirk,

I understand. When it stopped at the first comma I wondered if that meant there had to be some sort of manual intervention and you've just confirmed that. Sadly I can't bulk replace because the keywords are going to be very image dependent. No worries, I'll seek alternate routes. I'm determined not to do this manually!

Before I started diving into scripting and stuff in spreadsheets or elsewhere I wanted to make sure there wasn't a simple way to do it in PM! :) 

Thanks for your advice & happy holidays!

J

Offline Luiz Muzzi

  • Hero Member
  • *****
  • Posts: 704
    • View Profile
    • Luiz Muzzi Photography
Re: Code Replacements (or additions) on a string of existing keywords
« Reply #9 on: December 20, 2014, 07:09:18 AM »
Hi,
I do think that Find and Replace would work in such a situation. It works pretty well on a Mac.
HTH,

-Luiz Muzzi

Offline jaybee

  • Newcomer
  • *
  • Posts: 11
    • View Profile
Re: Code Replacements (or additions) on a string of existing keywords
« Reply #10 on: December 20, 2014, 07:46:57 AM »
Hi,
I do think that Find and Replace would work in such a situation. It works pretty well on a Mac.
HTH,

-Luiz Muzzi

Luiz,  Thanks for the idea but I don't think you understand what I need here.

Find & Replace only works on one search term at a time and it's manual. I need multiple search & replace operations anywhere in the IPTC Keyword field running automatically. It's clear PM cannot do this. Thanks, I'm exploring other solutions.

J

Offline Hayo Baan

  • Uber Member
  • ******
  • Posts: 2552
  • Professional Photographer & Software Developer
    • View Profile
    • Hayo Baan - Photography
Re: Code Replacements (or additions) on a string of existing keywords
« Reply #11 on: December 20, 2014, 11:33:41 AM »
Take a look at exiftool. Though not straightforward (you'll need to make use of some of its more advanced features), you can certainly accomplish what you want.

At the moment I don't have time to give you an example, but if you need some help later on, please don't hessitate to let me know.
Hayo Baan - Photography
Web: www.hayobaan.nl

Offline jaybee

  • Newcomer
  • *
  • Posts: 11
    • View Profile
Re: Code Replacements (or additions) on a string of existing keywords
« Reply #12 on: January 05, 2015, 06:33:04 AM »
Take a look at exiftool. Though not straightforward (you'll need to make use of some of its more advanced features), you can certainly accomplish what you want.

At the moment I don't have time to give you an example, but if you need some help later on, please don't hessitate to let me know.

Thanks Hayo, EXIF tool is very powerful but not easy to script  :o :)  Anyhow, I do have a solution to my needs. I'm using PM to output the Keywords as a text file, then doing the replacement/additions on that text file (using a text find/replace engine) and then re-importing the amended keyword strings into PM via code replacements.

That does exactly what I want.

Cheers

J