Batch addition of comments from files using wildcards

Started by Daniel Eaton, June 06, 2013, 01:42:30 PM

Previous topic - Next topic

Daniel Eaton

I am a fractal artist.  I now have all my work uploaded to Flickr.  What I am wanting to do is to embed the parameters for my fractals into the images themselves before loading them to Flickr.  For each JPG in my folder, I have an associated FLAME file (that is the file extension).  I know that I can do a  exiftool "-Comment<=test.flame" test.jpg  to load the comments - one at a time.  But I would also prefer to load the IPTC caption/description with that parameter data instead and load the comments with some standard boilerplate stuff (like URLs and such).  And I'd prefer to do this with wildcards.  Ultimately, I would love to run a command that would take the flame file and load it into the caption/description, load some standard boilerplate into the comments, and only process items that have no comments already.  Any help y'all can give a real newbie on this would be greatly appreciated.  I just can't figure out the wildcard part of this and cannot locate information on the caption/descirption IPTC field.


Phil Harvey

I don't know how you intend to expand the wildcards.  If it is from information in your FLAME file, then you would have to write a custom script to do this.  A specific example would be helpful.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Daniel Eaton

Wow!  That was quick!  :)  My current work folder has the following files in it:
2013-06-06_08-03-35.flame
2013-06-06_08-03-35.png
2013-06-06_08-03-37.flame
2013-06-06_08-03-37.png
2013-06-06_08-04-02.flame
2013-06-06_08-04-02.png
2013-06-06_08-13-56.flame
2013-06-06_08-13-56.png
2013-06-06_09-10-50.flame
2013-06-06_09-10-50.png
2013-06-06_09-15-18.flame
2013-06-06_09-15-18.png
2013-06-06_09-18-40.flame
2013-06-06_09-18-40.png
2013-06-06_09-20-48.flame
2013-06-06_09-20-48.png
2013-06-06_09-21-14.flame
2013-06-06_09-21-14.png
2013-06-06_09-27-13.flame
2013-06-06_09-27-13.png

Pretend all those PNG files have already been converted to JPG.  :)  What I'd like to do is run a command that would load boilerplate.txt into the JPG comments and the associated .flame file into the JPG caption/description fields for every image that does not already have comments. 


Phil Harvey

Something like this?:

exiftool "-comments<=boilerplate.txt" "-description<=%d%f.flame" -if "not $comments" -ext jpg DIR

(use single quotes instead of double quotes if you are on Mac or Linux)

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Daniel Eaton

I get an error:

C:\Temp\JPG Comment Test>exiftool "-comments<=boilerplate.txt" "-description<=%d%f.flame" DIR
Error opening file DIR.flame
Error: File not found - DIR
    0 image files updated
    1 files weren't updated due to errors


When I replace "DIR" with a specific file name, I get the error:
Warning: Sorry, comments is not writable
    1 image files updated

And nothing shows up in either the comments or the description.

Phil Harvey

Yes, by "DIR" I meant the actual directory name (or a file name works too).

And sorry.  It should be -comment, not -comments.

But your Description should have been written.  Use "exiftool -description FILE" to read it back again.  Then see FAQ 3 if you still have problems.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Daniel Eaton

Thanks.  That mostly works now. :)  Irfanview does not see the caption/description data, but exiftool does display it as being in there - and Flickr recognizes it as well.  I used the command exiftool -a -G1 -s 2013-05-31_18-51-11.jpg to discover that the data in what Irfanview called caption/description is stored in what ExifTool sees as "Caption-Abstract".  But that is OK.  Since IrfanView will not display description and Flickr will, I'll just keep it the way it is now (or load them into comments instead of description) and use other fields like Software, Artist, and Creator to plug in the "boilerplate".  :)

Daniel Eaton

One last question and I think I can stop bothering you for a while. :)  I have a VERRRRY long command line now that I am also loading up a lot of other fields and not just the comments.  So I created a batch to run it.  The only problem is that when the batch file runs, the %d%f.flame gets converted into "f.flame" and I get an error that it cannot locate "f.flame".  I know this is a Windows/DOS issue because when I copy that line out of the batch file and paste it into a DOS window, it runs without any problems at all.  Got any ideas on this one?

Phil Harvey

The "%" character is special in a Windows BAT file, and all "%" characters must be doubled like this: "%%".    This is all mentioned in the application documentation:

-TAG<=DATFILE or -TAG<=FMT]
    Set the value of a tag from the contents of file DATFILE. The file name may also
    be given by a FMT string where %d, %f and %e represent the directory, file name
    and extension of the original FILE (see the -w option for more details).
...

-w[+|!] EXT or FMT (-textOut)
...
    Notes:
    1) In a Windows BAT file the % character is represented by %%, so an argument
    like %d%f.txt is written as %%d%%f.txt.


- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Daniel Eaton

Thanks, Phil.  I think I have it all worked out now.  It's an amazing program.