ExifTool Forum

ExifTool => Newbies => Topic started by: Randall on May 04, 2018, 09:35:31 PM

Title: How to add several different IPTC messages in rotation on a thousand photos
Post by: Randall on May 04, 2018, 09:35:31 PM
I have just discovered this wonderful tool - thank you!

I shoot road running events, and my current work flow has been using Picassa, with dual uploads, first to Facebook for ease of discovery and sharing, but also placing the albums into Google Photos so participants could find a file number to request an watermarked original.  Google's recent disabling of the ability to upload new albums from Picassa, eventually brought me to this post (https://www.dpreview.com/forums/post/29639502) where I discovered way to use this ExifTool to add the file names as captions in the IPTC field (which would allow me to have the image names show as comments in a Facebook upload).

First Question: 

I created a .bat file as the referenced post suggested, but was unable to figure out what the syntax should be to have it operate on the image files within the same folder.  I know I have it installed correctly, as it did work brilliantly when I added the path to the folder in to the command - just not without.

This worked:  exiftool "-iptc:caption-abstract<filename" C:\\Users\etc\etc

How do I adjust this command to remove the dedicated folder location, and instead have the tool convert the images resident in the same folder as the .bat file?

Second Question:

Now that I can add captions, and they will show in Facebook (Which is SO awesome!), I'd like to mix static and dynamic information.  I'd like to have the file names, plus a set of perhaps 4 -7 short messages, that would also be added to this caption field, on a rotating basis:

IMG1001.JPG  First message
IMG1002.JPG  Second message
IMG1003.JPG  Third message
IMG1004.JPG  Fourth message
IMG1005.JPG  First message
IMG1006.JPG  Second message
etc...

Is there someone here that can help me figure out how to set this up?

Thank you!


Title: Re: How to add several different IPTC messages in rotation on a thousand photos
Post by: Phil Harvey on May 04, 2018, 10:19:50 PM
Quote from: Randall on May 04, 2018, 09:35:31 PM
How do I adjust this command to remove the dedicated folder location, and instead have the tool convert the images resident in the same folder as the .bat file?

Odd question.  I don't know how to get the location of the .bat file as a variable in the .bat file.  Normally one would use "%*" in the .bat file then drag and drop the folder onto the .bat file.

QuoteNow that I can add captions, and they will show in Facebook (Which is SO awesome!), I'd like to mix static and dynamic information.  I'd like to have the file names, plus a set of perhaps 4 -7 short messages, that would also be added to this caption field, on a rotating basis:

This is tricky, but could be accomplished fairly easily with a user-defined Composite tag.  I could also do it with a rather complex advanced-formatting expression.  I'll see about giving you something more specific when I get the time (maybe within the next couple of days).  It will take a bit of thought.

- Phil
Title: Re: How to add several different IPTC messages in rotation on a thousand photos
Post by: Randall on May 04, 2018, 10:58:25 PM
Thank you Phil for the prompt response.

I am only assuming the first can be done based on the referenced post from ten years ago:

QuoteSo far so good. Now... wipe through and copy this next line -

exiftool "-IPTC:Caption-Abstract

Then, Open Notepad, paste the line into it, and save the file as

Filename2Caption.bat

Now, copy the Filename2Caption.bat file into each folder where you
have photos you want to work with. Once the file is copied there,
double-click it to run it.

But I didn't understand the way it was worded, and looks like maybe some info is missing


Regarding the second, if you can help me get this set up and running inside the next week or so, it'd be of great use to me for a large event coming up, and I'd be very pleased to hire you to do so, or make a donation to the forum or the charity of your choice by way of thanks.
Title: Re: How to add several different IPTC messages in rotation on a thousand photos
Post by: Phil Harvey on May 05, 2018, 06:20:58 AM
Quote from: Randall on May 04, 2018, 10:58:25 PM
Once the file is copied there,
double-click it to run it.

This may work if the working directory is set to where the .bat was executed and you specify "." for the directory name.  But I'm not on Windows and can't test this right now.

Quote
Regarding the second, if you can help me get this set up and running inside the next week or so, it'd be of great use to me for a large event coming up, and I'd be very pleased to hire you to do so, or make a donation to the forum or the charity of your choice by way of thanks.

Sure.  I should get some time this weekend.

- Phil
Title: Re: How to add several different IPTC messages in rotation on a thousand photos
Post by: Phil Harvey on May 06, 2018, 05:06:43 PM
OK, here's what I came up with:

exiftool -userparam 1="test" -userparam 2="this" -userparam 3="out" "-caption-abstract<${filename;$$self{C}=1 unless $$self{C} and $self->Options(UserParam=>++$$self{C});s/$/' '.$self->Options(UserParam=>$$self{C})/e}" DIR

You can add as many UserParam's as you want, named 1, 2, 3, etc...

The Caption-Abstract will get set from the file name plus the rotating user parameters that you set.

- Phil
Title: Re: How to add several different IPTC messages in rotation on a thousand photos
Post by: Randall on May 07, 2018, 04:36:27 PM
Thanks Phil,

I tested your suggestion as written, on a test folder with seven images, and it did apply the correct file name for each, but used the same message (the first one) for all the photos.

These were the resulting captions:
0U1A4514.JPG test
0U1A4515.JPG test
0U1A4516.JPG test
etc...

So something isn't clicking quite yet right.  (I am working on Windows 7 if that could make any difference?)

Also, from reading through other answered question on the forum, I have discovered a couple of extra ideas:

a) can the variable text options be served from a csv file for ease of changing from use-to-use (so I change the csv file, not the .bat file)?
b) could there be a line break in the function so the caption displays in a more readable form?

I am thinking the finished  caption would display like this:
QuoteFile name: 0U1A4514.JPG

This is the variable text to accompany this photo and this is the website:http://www.website.com

Thank you!
Title: Re: How to add several different IPTC messages in rotation on a thousand photos
Post by: Phil Harvey on May 07, 2018, 07:49:18 PM
Can you paste the exact command you used?  The "C" must be upper case or you will get what you mentioned.

Getting the descriptions from CSV would be difficult.  Inserting a line break would be easy.

- Phil
Title: Re: How to add several different IPTC messages in rotation on a thousand photos
Post by: Randall on May 07, 2018, 08:40:42 PM
Thanks Phil.

I copied your exact phase, and added the specific directory where the photos were located.

Attached is a screen shot of the command and result:

Title: Re: How to add several different IPTC messages in rotation on a thousand photos
Post by: Phil Harvey on May 07, 2018, 09:46:24 PM
OK, thanks.  I'll have to try this on Windows to see why it didn't work, but I won't be able to do that until tomorrow.

- Phil
Title: Re: How to add several different IPTC messages in rotation on a thousand photos
Post by: Hayo Baan on May 08, 2018, 04:46:36 AM
Hi Phil, your command didn't work for me either. The problem is that somehow $$self{C} gets undefined each time.
Title: Re: How to add several different IPTC messages in rotation on a thousand photos
Post by: Randall on May 08, 2018, 06:38:43 AM
I am thinking there is another way at this, though perhaps not as elegant (and leans on the fact I am comfortable in Excel)

After shooting and light editing of my photos, there is an exif command I could use that would export a csv file containing the proper path to each image in the folder.

Then, with this information in Excel, I could arrange the filenames and assorted bits and pieces to assemble the captions as I wanted them, and concatenate to a single column (matched with the image file locations).

Then, using a csv file of assembled individual captions matched to each image file location, there is another exif command that would allow me to mass import these captions back to the original image folder, and from there upload my images with captions attached.

That would give me a three step process:

Thinking that through though, once this function you have provided is working, I could also break that function down into an excel worksheet where I could easily concatenate the new adjusted exif command line for each project I am working on  (just thinking of how I easily modify this into the future with out messing it up along the way! ;) )
Title: Re: How to add several different IPTC messages in rotation on a thousand photos
Post by: Phil Harvey on May 08, 2018, 07:18:34 AM
Quote from: Hayo Baan on May 08, 2018, 04:46:36 AM
Hi Phil, your command didn't work for me either. The problem is that somehow $$self{C} gets undefined each time.

Hayo is right.  I was testing with -p instead of copying the tag.  When copying, ExifTool creates a new reader object for each file so this didn't work.  It works if I use a global variable instead:

exiftool -userparam 1="test" -userparam 2="this" -userparam 3="out" "-caption-abstract<${filename;$::c=1 unless $::c and $self->Options(UserParam=>++$::c);s/$/' '.$self->Options(UserParam=>$::c)/e}" DIR

- Phil
Title: Re: How to add several different IPTC messages in rotation on a thousand photos
Post by: Phil Harvey on May 08, 2018, 07:22:06 AM
Quote from: Randall on May 08, 2018, 06:38:43 AM
I am thinking there is another way at this, though perhaps not as elegant (and leans on the fact I am comfortable in Excel)

After shooting and light editing of my photos, there is an exif command I could use that would export a csv file containing the proper path to each image in the folder.

The -csv option does this automatically.  Try this:

exiftool -csv -filename DIR > out.csv

You can then edit the CSV (change the FileName column heading to Caption-Abstract and edit these values as desired), and import it again like this:

exiftool -csv=out.csv DIR

- Phil
Title: Re: How to add several different IPTC messages in rotation on a thousand photos
Post by: Randall on May 08, 2018, 06:21:47 PM
Thank you, Phil.

I have just used your phrase from Reply 11 above - man, that is slick.

I know I could do what I want with adding the excel stage, but it will never be as slick as doing it this way, so that leads me to a couple more questions to see if I can get the other few items I have imagined included:
[/li]
[/list]

( I recognize this may or may not work like I want once uploaded to a Facebook photo album, so I will need to test it out)

Finally, are there any practical limits I will run into if this command gets large - for example, say I had 15 different userparams, each 100 characters long, does the phrase at any point get too long to process?  Or is there any limit to the number of photos in a folder that could be processed?

Thanks, R.
Title: Re: How to add several different IPTC messages in rotation on a thousand photos
Post by: Phil Harvey on May 09, 2018, 07:37:09 AM
Hi Randall,

Quote from: Randall on May 08, 2018, 06:21:47 PM
  • In what you have created, can I also preface the variable file name with a static portion, the same for all the images, so the output looks like this: "File name: UA0012.JPG"
  • How do I indicate a line return, ideally two, leading the phrase in each userparam, so that the file name information can be separated from the message

Something like this should do it:

exiftool -userparam 1="test" -userparam 2="this" -userparam 3="out" "-caption-abstract<${filename;$::c=1 unless $::c and $self->Options(UserParam=>++$::c);$_='File name: '.$_.qq(\n\n).$self->Options(UserParam=>$::c)}" DIR

QuoteFinally, are there any practical limits I will run into if this command gets large - for example, say I had 15 different userparams, each 100 characters long, does the phrase at any point get too long to process?  Or is there any limit to the number of photos in a folder that could be processed?

I suggest doing this:

exiftool -@ myparams.txt "-caption-abstract<${filename;$::c=1 unless $::c and $self->Options(UserParam=>++$::c);$_='File name: '.$_.qq(\n\n).$self->Options(UserParam=>$::c)}" DIR

"myparams.txt" would contain:

-userparam
1=test
-userparam
2=this
-userparam
3=out


then you don't have to worry about Windows command-line length limitations.

- Phil
Title: Re: How to add several different IPTC messages in rotation on a thousand photos
Post by: Randall on May 19, 2018, 09:20:43 AM
This is cool, I have it working on my laptop, and will have the first real test this weekend.

One final detail (and this may be a Facebook specific question as that is my destination for these shots/captions), is there a command that will insert two line returns or a paragraph return into the captions?

Currently I have this output:
QuoteEvent Name & Image Number  Lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum

My ideal would be:
QuoteEvent Name & Image Number

Lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
Title: Re: How to add several different IPTC messages in rotation on a thousand photos
Post by: StarGeek on May 19, 2018, 11:26:10 AM
Quote from: Randall on May 19, 2018, 09:20:43 AMis there a command that will insert two line returns or a paragraph return into the captions?

See FAQ 21 (https://exiftool.org/faq.html#Q21).

I find option b to be the easiest under Windows.
Title: Re: How to add several different IPTC messages in rotation on a thousand photos
Post by: Randall on May 19, 2018, 05:00:42 PM
I think I asked that last question too soon!  As it turns out, the line break wasn't showing on my computer, but once I uploaded to Facebook, it is *exactly* as I wanted   :D :D :D
Title: Re: How to add several different IPTC messages in rotation on a thousand photos
Post by: StarGeek on May 19, 2018, 05:07:25 PM
Ah, yes.  Checking your first post I see you mention Picasa, and Picasa doesn't show line breaks.  Overall, it's pretty poor with it's metadata management, though I still use it for it's facial recognition ability.