Author Topic: Now for something completely different....  (Read 6302 times)

Offline JS

  • Full Member
  • ***
  • Posts: 209
    • View Profile
Now for something completely different....
« on: April 29, 2019, 02:28:03 PM »
...not PM6 related. Generally I caption my photos in this order: "continent, country, state, city, description what's shown". For a new agency I need it now exactly the opposite way: "description what's shown ...up to... continent". Is there a way to turn it around in PM in batch automatically?

-John
« Last Edit: April 29, 2019, 02:40:01 PM by Kirk Baker »

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 24756
    • View Profile
    • Camera Bits, Inc.
Re: Now for something completely different....
« Reply #1 on: April 29, 2019, 02:41:09 PM »
...not PM6 related. Generally I caption my photos in this order: "continent, country, state, city, description what's shown". For a new agency I need it now exactly the opposite way: "description what's shown ...up to... continent". Is there a way to turn it around in PM in batch automatically?

I'm sorry but I don't understand what you're asking to be able to do?  Do you want to rearrange the order in which fields appear in the Metadata dialogs?

-Kirk

Offline Hayo Baan

  • Uber Member
  • ******
  • Posts: 2552
  • Professional Photographer & Software Developer
    • View Profile
    • Hayo Baan - Photography
Re: Now for something completely different....
« Reply #2 on: April 29, 2019, 08:13:08 PM »
@Kirk, no, I think JS just wants to change the order in his existing captions.

@JS, do you have the caption parts available in separate metadata fields? Then it would be doable by using variables representing those parts as new caption in the metadata template. However, I expect not all parts (description most likely not to begin with) will be available as separate entities, so this won't work.

If you're not afraid of using exiftool on the command-line, I probably could come up with some fancy command to achieve what you want, assuming all your captions are formatted EXACTLY as you describe and without any comma in the continent, country, state, or city names.
Hayo Baan - Photography
Web: www.hayobaan.nl

Offline JS

  • Full Member
  • ***
  • Posts: 209
    • View Profile
Re: Now for something completely different....
« Reply #3 on: May 02, 2019, 01:56:00 PM »
Sorry for late reply. I was very busy the last days. Hayo, You understand me right. I was thinking about variables too, but as You said the description part would be the problem. My captions are formatted exactly like I described. Exiftool, I just don't know it. Isn't it a Windows-Prog? I'm on a Mac.

Offline Hayo Baan

  • Uber Member
  • ******
  • Posts: 2552
  • Professional Photographer & Software Developer
    • View Profile
    • Hayo Baan - Photography
Re: Now for something completely different....
« Reply #4 on: May 02, 2019, 09:53:54 PM »
Hi JS, exiftool is a tool (script) that runs on Mac, unix, and Windows. It's extremely powerful and supports almost all image formats and metadata. Be sure to check it out. :)

Here's the link to the exiftool website: https://sno.phy.queensu.ca/~phil/exiftool/
« Last Edit: May 02, 2019, 10:26:13 PM by Hayo Baan »
Hayo Baan - Photography
Web: www.hayobaan.nl

Offline JS

  • Full Member
  • ***
  • Posts: 209
    • View Profile
Re: Now for something completely different....
« Reply #5 on: May 03, 2019, 05:02:21 PM »
Hi Hayo,

this side looks really frightening for me. I better don't use it! But thanks anyhow for Your effort.

-John

Offline Hayo Baan

  • Uber Member
  • ******
  • Posts: 2552
  • Professional Photographer & Software Developer
    • View Profile
    • Hayo Baan - Photography
Re: Now for something completely different....
« Reply #6 on: May 03, 2019, 11:42:28 PM »
this side looks really frightening for me. I better don't use it! But thanks anyhow for Your effort.

Hi John,

It's not that bad. I could tell you what the exact command would need to be. You'd test that on a couple of images and then you could run it on all.  But it would still require you go do stuff on the command-line, that I can't help ;)
Hayo Baan - Photography
Web: www.hayobaan.nl

Offline JS

  • Full Member
  • ***
  • Posts: 209
    • View Profile
Re: Now for something completely different....
« Reply #7 on: May 04, 2019, 07:05:39 AM »
Hi Hayo,

well, let's try. I hope I'm not wasting Your time?

-John

Offline Odd Skjaeveland

  • Full Member
  • ***
  • Posts: 188
    • View Profile
Re: Now for something completely different....
« Reply #8 on: May 04, 2019, 09:00:12 AM »
...well, let's try. I hope I'm not wasting Your time?

If you feel more confident using a regular expression capable text editor, there is another approach that may work.
1) Select some images
2) File -> Export with the Text Exporter template, put {filename},{caption} in the middle text field, everything else empty/unchecked but do select "Save all as one file" and click Export.
3) Load the exported text file in a text editor that can do regular expression search and replace

Here is a fictitious sample for such export from three selected images, one line per image:

L1000398.DNG,CONT-1,CTRY-A,ST-01,CITY-1,Descr no commas.
L1000399.DNG,CONT-2,CTRY-B,ST-02,CITY-2,Descr, one comma.
L1000400.DNG,CONT-3,CTRY-C,ST-03,CITY-3,Descr, one comma, nono, three commas

The format is
<filename>,<continent>,<country>,<state>,<city>,<description>

The last five fields are from your current caption.

Now use a regular expression find and replace to modify those three lines into

L1000398.DNG   Descr no commas:CONT-1,CTRY-A,ST-01,CITY-1
L1000399.DNG   Descr, one comma:CONT-2,CTRY-B,ST-02,CITY-2
L1000400.DNG   Descr, one comma, nono, three commas:CONT-3,CTRY-C,ST-03,CITY-3

Note that a TAB character now separates filename from the new caption string. PM wants a TAB separator.
Also note that I used a colon (rather than a comma) to indicate the end of the description in the new caption text.

I attach two screen dumps that show how I did this in the Notepad++ editor for Windows. Any text editor capable of regular expression search and replace should be able to do the same, though regexp syntax may be different. Please ask if you find the search and replace expressions intimidating. I am on the road and may  not be able to answer the next few days, but I am sure Hayo and others understand it and may help.

Save the result as a new text file. Then use the new text file as explained in reply #9 by Kirk Baker in this thread about "Bulk caption edit": http://forums.camerabits.com/index.php?topic=11149.0 
 


 
--
Odd S.

Offline JS

  • Full Member
  • ***
  • Posts: 209
    • View Profile
Re: Now for something completely different....
« Reply #9 on: May 04, 2019, 10:42:51 AM »
Hi Odd,

"intimidating" is the right word. But as far as I understand Your examples, they don't change the order of "Continent", Country", "State" and "City".

-John

Offline Odd Skjaeveland

  • Full Member
  • ***
  • Posts: 188
    • View Profile
Re: Now for something completely different....
« Reply #10 on: May 04, 2019, 12:40:23 PM »
"intimidating" is the right word. But as far as I understand Your examples, they don't change the order of "Continent", Country", "State" and "City".

You can easily change that around as you please. The search splits the original line into 6 numbered elements 1,2,3,4,5,6. Actually called groups 1, 2, 3, 4, 5 and 6  in regexp lingo, you can identify the match code  between parenthesis () in the search expression. Count them and map them to the original lines as exported by PM.

1=filename
2=continent
3=country
4=state
5=city
6=description

The replace string refers to those 6 elements (groups) using $<digit> references, $1 refers to element (group) 1, the first parenthesis in the search expression.

$1\t$6:       gives you <filename>TAB<description>:
$1\t$6:$5,  gives you  <filename>TAB<description>:<city>,
$1\t$6:$5,$4,  gives you  <filename>TAB<description>:<city>,<state>,
$1\t$6:$5,$4,$3,  gives you  <filename>TAB<description>:<city>,<state>,<country>
$1\t$6:$5,$4,$3,$2  gives you  <filename>TAB<description>:<city>,<state>,<country>,<continent>

You should be able to play with those $<digit> references to get their content where you like to have them. You can refer to the same element (group) more than once, and you can leave any reference out of the replacement string.

Some regexp systems may require a backslash rather than the dollar character in group references, meaning $1 must be written \1, $2 must be written \2 and so on, and some systems will work equally well with $<digit> and \<digit>. You will have to find out what your editor requires. Just try with a small sample to see what happens.
 
Now put the content of those 6 elements (groups)  wherever you want a copy on the result line by referring to those numbers. $1 will give you the filename, $2 will give you the continent, ...,$6 will give you the description. If you don't like my order, put those $<digit> references in your preferred order. If you don't like my separator characters (colon and comma), provide your own. Let the $1 and the TAB separator (\t) alone, that is what PM expects if you follow the description I linked to.

I hope this helps if you decide to try this alternative. I would have used Hayo's solution myself, but that is not relevant.
--
Odd S.

Offline Hayo Baan

  • Uber Member
  • ******
  • Posts: 2552
  • Professional Photographer & Software Developer
    • View Profile
    • Hayo Baan - Photography
Re: Now for something completely different....
« Reply #11 on: May 04, 2019, 10:05:58 PM »
well, let's try. I hope I'm not wasting Your time?

Hi John, the exiftool command would be something like this:
Code: [Select]
exiftool '-caption<${caption; s/([^,]*),\s*([^,]*),\s*([^,]*),\s*([^,]*),\s*(.*)/$5, $4, $3, $2, $1/s;}' FILESorDIRSwhere FILESorDIRS is the files you want to have it run on (you could drag files from the finder onto the terminal as well.

For safety, exiftool always reserves the original in a file called FILE_orginal, so you can always revert the changes. If you're happy with the changes, you can prevent creation of the _original file by adding the option -overwrite_original, to also preserve the file modification time, add -P as well (capital P!).

Note: it could be that the caption is not (only) in the Caption field, in that case you may need to use the same construct on other fields as well.

Try it on one or more files and see if this does what you want.

Cheers,
Hayo

Hayo Baan - Photography
Web: www.hayobaan.nl

Offline JS

  • Full Member
  • ***
  • Posts: 209
    • View Profile
Re: Now for something completely different....
« Reply #12 on: December 01, 2019, 04:23:23 AM »
Hi,

and thanks a lot to everybody who tried to help. I was seek for quite long time and photography was far from me. Later I forgot about this post. Btw, it didn't work like suggested(or I was to stupid). Now it's not so necessary anymore.

Regards
John

Offline Hayo Baan

  • Uber Member
  • ******
  • Posts: 2552
  • Professional Photographer & Software Developer
    • View Profile
    • Hayo Baan - Photography
Re: Now for something completely different....
« Reply #13 on: December 01, 2019, 10:10:54 AM »
Hmm, the command I gave you should have worked, unless the caption in fact did not contain the string in the formatting you described. Or you ran it on Windows, in which case replacing the single quotes with double quotes would have been necessary. But like you said, you don't need this any longer ;D
Hayo Baan - Photography
Web: www.hayobaan.nl

Offline rread

  • Newcomer
  • *
  • Posts: 1
    • View Profile
    • Professional Headshots NYC
Re: Now for something completely different....
« Reply #14 on: December 06, 2019, 06:45:06 AM »

Code: [Select]
exiftool '-caption<${caption; s/([^,]*),\s*([^,]*),\s*([^,]*),\s*([^,]*),\s*(.*)/$5, $4, $3, $2, $1/s;}' FILESorDIRS

Hayo, I had no idea exiftool supported expressions like that. Definitely good to know.

Thanks,
Robert