Hi,
I've started using Filename2Caption add-on for Picasa -
https://sites.google.com/site/picasastartersite/custom-picasa-buttons/filename2caption (https://sites.google.com/site/picasastartersite/custom-picasa-buttons/filename2caption)
This batch file command result is the file-name as the image caption.
I would like to have the folder-name as the caption.
Specific, 'real' examples:
a. Image File --> H:\ASI\Travel & Photos\Ireland & Scotland (and Prague)\Photographs\Ireland\0803\Galway\x.jpg
'Wanted' result --> x.jpg Image caption: "Galway"
b. Image File --> H:\ASI\Travel & Photos\China\Guilin\Seven Stars Park\Seven Stars Cave\y.tif
'Wanted' result --> y.tif Image caption: "Seven Stars Cave"
c. Image File --> H:\ASI\Travel & Photos\France\Photographs\Paris\050813\8th of May WWII Ceremony\z.dng
'Wanted' result --> z.dng Image caption: "8th of May WWII Ceremony"
So bottom line, I reckon that I'm basically asking what to change in the batch file line:
'"%BatFileDir%\exiftool.exe" -overwrite_original "-xmp:description=%~n1" "-iptc:caption-abstract=%~n1" %1
In order to get the above expected result.
specific assistance will be much appreciated.
Thank you!
Doing what you want requires a simple filtering to remove all but the last directory name. I think this should do it:
"%BatFileDir%\exiftool.exe" -overwrite_original "-xmp:description<${directory;s(.*/)()}" "-iptc:caption-abstract<${directory;s(.*/)()}" %*
This should work if Picasa passes the directory name to exiftool (as opposed to setting the working directory before calling exiftool).
- Phil
Edit: remove extra quotation mark from command
Wow, a reply from the great Phil Harvey himself, I'm truly honored ;D
anyhow, for some reason I get the following error:
Busy processing file "H:\ASI\Travel & Photos\Israel\Docs\Israel_map.jpg"
The system cannot find the file specified.
The system cannot find the path specified.
Press any key to continue . . .
Now the file is present in that dir... so I'm clueless :-(
FYI: the original batch file can be downloaded from here:
http://picasastarter.googlecode.com/files/PS_ButtonFile2Caption.bat (http://picasastarter.googlecode.com/files/PS_ButtonFile2Caption.bat)
Please Help me :)
I can't help much with the Picasa end of things, which seems to be the problem here. Perhaps you should change back from %* to the %1 you had originally. Other than that I can't guess at the problem. It may help to try the exiftool command directly from the cmd.exe window to see if it works.
- Phil
nope, same error.
I thought about trying running this directly via ExifTool but the problem is:
a. Since I use Picasa as my photo organizer and uploader to google photos, I'm interested in automating captioning of the images I have uploaded and sorted in albums only (as opposed to auto captioning all images in any folder for instance)
b. as a folder name is not a part of any metadata info of a file, even if I somehow manage to get this task automated by using ExifTool (which is difficult for me as I have no inclination for programming), I reckon that I would still be limited to a single folder at a time. This is a great drawback since my photos are tightly structured in a hierarchical folder structure (something like: _location_date_place_ | and I have ~15k images), which will mean that if for example I've created an album from images taken from different folders I will have to go to each folder and run the ExifTool Command.
That is assuming I successfully mastered the appropriate ExifTool command, which I did not :-(
any suggestions / advice ?
Thanks in advance!
From the command line, this will work for a deep hierarchy of a large number of images:
exiftool -overwrite_original "-xmp:description<${directory;s(.*/)()}" "-iptc:caption-abstract<${directory;s(.*/)()}" -r DIR
where DIR is the root folder name. Note that this will process all writable files in the directory and its subdirectories, so it is a very powerful command, and it is best to try it out on a test directory first. See the ExifTool home page (https://exiftool.org) for a list of writable file formats.
- Phil
Thanks!
Though I'm a little wary of using such a powerful command, as this would mean that all my ~15k images will be modified (assuming all goes well without a glitch).
The problem is that I don't have a spare backup of my entire photos library -
I had 2 external USB Seagate Free-agent drives. One started showing bad sectors, so I was left with only one copy of my images.
So I opted to backup what I can on the google cloud (google photos for that matter, on a 100GB plan in order to be able to upload more full size images).
Unfortunately my up-connection is quite mediocre and in any-case it's not enough space if I count all the ~15k images (a handful are DNG and TIF images).
Therefor I perform some measures of screening before uploading it to the cloud.
...So this brings me back to my original problem :-[
well, the way things stand as I see it, I guess I'll have to either:
a. take my chances with the super-command
or
b. If I'm really interested in captioning the ~2000+ photos I already uploaded to the cloud in the way I desire to, I'll just have to resort back the to good ol' manual labor for the task at hand.
BTW,
As a long shot, I've opened a thread at the google Picasa forums about the error I encountered with your original command line modification suggestion
(For what it's worth,I apologize for not asking for your permission in advance).
Thanks anyway!
Have you tried it on files that don't have an ampersand in the path? The ampersand is a special character in windows command line, used to separate two commands on the same line and your error message contains two error messages
"The system cannot find the file specified."
"The system cannot find the path specified."
The thing is, if this is the problem, it shouldn't be happening because the "Busy processing file" line shows that the path is encased in quotes, which should prevent the ampersand from being interpreted as a special character.
Ok, We have some progress - the error indeed was related to the ampersand in the folder path.
However, it still doesn't work - now the command is executed rapidly, and the cmd window closes by itself (which means no error occurred, according to the batch 'if' line) - but nothing happens, and the caption remains blank :-(
For verification, I tested the original filename2caption.bat and it works on the same file - the filename is entered in the caption correctly.
So now I guess we have a more complicated problem - perhaps something to the direction Phil has suggested ( the stage in which Picasa passes the folder path value).
a. suggestions anyone?
b. in addition, so it happens that my root dir of all my photos library is:
H:\ASI\Travel & Photos\...
I cannot change that (multiple dependencies in various programs).
How do I Instruct windows to relate to the '&' as a part of the folder path (as opposed to a special character)?
Thanks in advance!
Thanks in advance
Quote from: asiniv on December 13, 2015, 03:19:38 PM
How do I Instruct windows to relate to the '&' as a part of the folder path (as opposed to a special character)?
Quotes around the filename should do this, but isn't. The only other way would be to add a caret
^ before the ampersand before it gets passed to the batch file, but that isn't really an option.
Try this. Add:
echo %BatFileDir%
pauseto the end of the batch file and run it through picasa on your test file. This will output the path of the Batch file and will add another pause to keep the window open. You can then see all of the output and copy and post it here.
Busy processing file "H:\BACKUPS\Picasa Additions\Israel\test\test.jpg"
The system cannot find the file specified.
C:\Tools\PicasaScripts\
Press any key to continue . . .
a. So it turns out I'm still getting the same original error (one line error though, so it's not exactly the same as the ampersand problem), I've tried both with a '%1' and '%*' at the end of the command line.
I've also tested the original batch again to make sure it works, and it does ; so I assume it's not related to the folder's path characters .
any new directions of thought to what might be the cause of the problem?
b.
QuoteQuotes around the filename should do this, but isn't. The only other way would be to add a caret ^ before the ampersand before it gets passed to the batch file, but that isn't really an option.
So you mean to tell me the only option to solve this is change my root dir path?
Did you make the correction to the command line that Phil posted?
Looking back, from the time stamps on the posts, it appears that Phil posted the new command, you posted the error, and then Phil edited the post to correct the command line to remove an extra double quote. An extra double quote might cause this problem.
Aha! I missed that part (I apologize for my lack of fine attention to 'subtle' changes) :o
Final command line used:
"%BatFileDir%\exiftool.exe" -overwrite_original "-xmp:description<${directory;s(.*/)()}" "-iptc:caption-abstract<${directory;s(.*/)()}" %*
So now it finally works!!!
A couple of minor questions:
1. when performing different test trials on my test.jpg I've noticed that if the file previously had a caption ('test' for example), and then I renamed the dir (to test2 for example), and then re-ran the batch, it DIDN'T update the caption.
only if I manually cleared the caption first and then ran it, it worked, though it issued a warning:
"
Busy processing file "H:\BACKUPS\Picasa Additions\Israel\test2\test.jpg"
Warning: [minor] Ignored empty rdf:Alt list for dc:description - H:/BACKUPS/Pica
sa Additions/Israel/test2/test.jpg
1 image files updated
C:\Tools\PicasaScripts\
Press any key to continue . . .
"
What is the meaning of this warning?
How Do I force the batch to overwrite existing caption (if there is one), or alternatively clear the caption first before updating it?
2. Any suggestions for a workaround regarding the folder name problem (as stated, I cannot change it due to multiple dependencies in various programs)
?
Thanks in advance!
Quote from: asiniv on December 14, 2015, 12:54:25 AM
1. when performing different test trials on my test.jpg I've noticed that if the file previously had a caption ('test' for example), and then I renamed the dir (to test2 for example), and then re-ran the batch, it DIDN'T update the caption.
only if I manually cleared the caption first and then ran it, it worked,
Do you mean that the caption didn't update in Picasa? Or did you check the caption with another program and it didn't change? I've had times when I change captions in other programs and Picasa didn't always update it right away. Try exiting Picasa and restarting to see if it gets updated. If that doesn't work, try removing the picture from Picasa and adding it back in.
Quote
though it issued a warning:
"
Busy processing file "H:\BACKUPS\Picasa Additions\Israel\test2\test.jpg"
Warning: [minor] Ignored empty rdf:Alt list for dc:description - H:/BACKUPS/Pica
sa Additions/Israel/test2/test.jpg
1 image files updated
This looks to me like the image was updated, but Picasa just didn't read the change. Odds are, if you run a command like
Exiftool -description -caption-abstract "H:/BACKUPS/Picasa Additions/Israel/test2/test.jpg", it will tell you that the description and caption-abstract have been updated.
QuoteWhat is the meaning of this warning?
I don't know the exact meaning of the warning, but when you clear out the caption in Picasa, it's writing the XMP data wrong in some way. I was able to replicate this on my side, so it's not just you. It's a minor error on Picasa's side and ExifTool is fixing it when it writes the description.
Quote2. Any suggestions for a workaround regarding the folder name problem
With the correction to the command line, this shouldn't be a problem anymore. The ampersand should no longer cause any problems since it is now quoted properly. Test it out to make sure, though.
Quote from: asiniv on December 14, 2015, 12:54:25 AM
Warning: [minor] Ignored empty rdf:Alt list for dc:description - H:/BACKUPS/Pica
What is the meaning of this warning?
It indicates that there is a list element in the XMP with no content. It is wasteful, but not a problem otherwise. This warning may safely be ignored. Using the
-m switch will suppress this warning.
- Phil
More progress - more problems:
Busy processing file "H:\ASI\Travel & Photos\Israel\Israel - Photographs\2013\08
3113\כנס במכון פוליס - מקורות האלפאבית\IMG_1554.tif"
Warning: Malformed UTF-8 character(s) - H:/ASI/Travel & Photos/Israel/Israel - P
hotographs/2013/083113/δ≡± ßεδσ∩ ⌠σ∞Θ± - ε≈σ°σ· Σα∞⌠αßΘ·/IMG_1554.tif
1 image files updated
Press any key to continue . . .
The end result is that no caption is saved in the image....
So this time it has something to do with the fact that I use Hebrew characters.
How can I solve this one?
(and here there's no way getting around it - Hebrew is my native language, so a large of volume of my images are stored in folders where the pass contains Hebrew characters).
Thanks in advance!
Did you try specifying -charset filename=utf8 in the exiftool options used by the script?
- Phil
For testing:
"%BatFileDir%\exiftool.exe" -charset filename=utf8 -overwrite_original "-xmp:description<${directory;s(.*/)()}" "-iptc:caption-abstract<${directory;s(.*/)()}" %*
I get the error:
Busy processing file "H:\ASI\Travel & Photos\Israel\Israel - Photographs\2013\08
3113\כנס במכון פוליס - מקורות האלפאבית\IMG_1554.tif"
Unknown type for -charset option: filename
Warning: Malformed UTF-8 character(s) - H:/ASI/Travel & Photos/Israel/Israel - P
hotographs/2013/083113/δ≡± ßεδσ∩ ⌠σ∞Θ± - ε≈σ°σ· Σα∞⌠αßΘ·/IMG_1554.tif
1 image files updated
What did I do wrong?
(I apologize for my ignorance in programming)
- also please notice that only the folders contain Heb. Chars.
Thx
You must be using an old version of ExifTool. The -charset filename option was added in version 9.79. Try updating to the most recent version. Actually, that alone may solve this problem.
- Phil
I've downloaded the latest exec from your website.
Now I get:
Busy processing file "H:\ASI\Travel & Photos\Israel\Israel - Photographs\2013\08
3113\כנס במכון פוליס - מקורות האלפאבית\IMG_1554.tif"
Invalid filename encoding for H:/ASI/Travel & Photos/Israel/Israel - Photographs
/2013/083113/δ≡± ßεδσ∩ ⌠σ∞Θ± - ε≈σ°σ· Σα∞⌠αßΘ·/IMG_1554.tif
Error opening directory H:/ASI/Travel & Photos/Israel/Israel - Photographs/2013/
083113/δ≡± ßεδσ∩ ⌠σ∞Θ± - ε≈σ°σ· Σα∞⌠αßΘ·/IMG_1554.tif
I've tried purging Picasa & IE cache files (Picasa uses IE interface) exit and re-open it. didn't do the trick.
Perhaps it's worth noting that the CMD window itself shows all the heb. chars. as gibberish (as opposed to the browser which displays the original folder path correctly when viewing this specific post).
Any ideas?
OK, so that didn't work. (Are you getting the impression that special characters in Windows filenames are a pain?)
So the file names are not specified in UTF8. What character set is your system using? If Latin2 for example, then try adding -charset exiftool=latin2 to the command so that ExifTool will translate from this to the appropriate character set.
- Phil
So, it turns out that my CMD shell wasn't configured for Hebrew characters correctly.
So I fixed that according to: http://ariely.info/Blog/tabid/83/EntryId/139/Windows-console-command-shell-Using-Local-Languages-En-US.aspx (http://ariely.info/Blog/tabid/83/EntryId/139/Windows-console-command-shell-Using-Local-Languages-En-US.aspx)
But now I get the error:
Busy processing file "H:\ASI\Travel & Photos\Israel\Israel - Photographs\2013\08
3113\כנס במכון פוליס - מקורות האלפאבית\IMG_1554.tif"
Warning: Error opening file - H:/ASI/Travel & Photos/Israel/Israel - Photographs
/2013/083113/δ≡± ßεδσ∩ ⌠σ∞Θ± - ε≈σ°σ· Σα∞⌠αßΘ·/IMG_1554.tif
Error: File not found - H:/ASI/Travel & Photos/Israel/Israel - Photographs/2013/
083113/δ≡± ßεδσ∩ ⌠σ∞Θ± - ε≈σ°σ· Σα∞⌠αßΘ·/IMG_1554.tif
0 image files updated
1 files weren't updated due to errors
Notice that the gibberish chars. in the error have changed to Cyrillic char set (I think), whereas the original path is correctly displayed in hebrew (I cannot exemplify this since it's auto corrected by chrome when I copy paste it to here).
My setup is according to your FAQ supported char sets - Hebrew (cp1255)
Just in case, I also tried CP862 (OEM), but it didn't work, so I guess it's not supported...
So, now what do I do?
chr*st, I think I'm going to cry... :'(
What exiftool options did you use in your last try. I suggest: -charset exiftool=cp1255
- Phil
I've tried:
"%BatFileDir%\exiftool.exe" -charset exiftool=cp1255 -charset filename=cp1255 -overwrite_original "-xmp:description<${directory;s(.*/)()}" "-iptc:caption-abstract<${directory;s(.*/)()}" %*
and am getting warning error:
Busy processing file "H:\ASI\Travel & Photos\Israel\Israel - Photographs\2013\08
3113\כנס במכון פוליס - מקורות האלפאבית\IMG_1554.tif"
Warning: Some character(s) could not be encoded in Latin - H:/ASI/Travel & Photo
s/Israel/Israel - Photographs/2013/083113/δ≡± ßεδσ∩ ⌠σ∞Θ± - ε≈σ°σ· Σα∞⌠αßΘ·/IMG_
1554.tif
1 image files updated
Final result: caption remains blank
am I missing an additional handle?
(as it still warns about 'Some... Latin' but not specific enough so I'll know what to add)
Still looks like your filenames are not in the same encoding as what exiftool thinks it is/what you tell it.
What code page is your terminal set to? Run the command chcp and tell us the outcome.
Quote from: asiniv on December 15, 2015, 12:42:10 AM
I've tried:
"%BatFileDir%\exiftool.exe" -charset exiftool=cp1255 -charset filename=cp1255 -overwrite_original "-xmp:description<${directory;s(.*/)()}" "-iptc:caption-abstract<${directory;s(.*/)()}" %*
and am getting warning error:
Busy processing file "H:\ASI\Travel & Photos\Israel\Israel - Photographs\2013\08
3113\כנס במכון פוליס - מקורות האלפאבית\IMG_1554.tif"
Warning: Some character(s) could not be encoded in Latin
Now we're making some progress. Assuming that the XMP:Description got written properly, then the remaining problem is the IPTC encoding. See FAQ 10 (https://exiftool.org/faq.html#Q10) for all of the details, but this is the command I would suggest:
"%BatFileDir%\exiftool.exe" -charset exiftool=cp1255 -charset filename=cp1255 -charset iptc=utf8 -codedcharacterset=utf8 -overwrite_original "-xmp:description<${directory;s(.*/)()}" "-iptc:caption-abstract<${directory;s(.*/)()}" %*Yes, this character encoding business is tricky. Especially on the Windows command line and particularly with IPTC.
- Phil
Hmmm... this is weird:
Active code page: 1255
Busy processing file "H:\ASI\Travel & Photos\Israel\Israel - Photographs\2013\08
3113\כנס במכון פוליס - מקורות האלפאבית\IMG_1555.tif"
1 image files updated
C:\Tools\PicasaScripts\
Press any key to continue . . .
Your command runs smoothly (I've added chcp 1255 beforehand to the batch file), and the caption is written in the IPTC info (verified externally with IrfanView).
HOWEVER, Picasa does not display it, which is even stranger as the original write2caption of the filename to the direction works in order and is recognized correctly by Picasa.
I've tried exit-reenter / clear cache / remove folder completely and re-scan it - nothing helped :-(
So now I'm confused:
Either there is still something erroneous related to the Heb. chars. encoding; Or maybe Picasa stores/writes the caption information in a different manner -
I've tried comparing my test file IPTC to another file without heb. chars. which was edited by Picasa - I could not spot any differences.
Or perhaps this is now strictly a Picasa issue?
What am I missing here? any suggestions?
Thx
You should be able to iterate a few times with Picasa to find the problem. First try this command on a file with a simple ASCII name and see if Picasa displays the caption. If not, then compare the output of "exiftool -a -G1" for this file and the same file with the same caption written by Picasa. This should show you the difference that is causing problems for Picasa.
- Phil
made a few more iterations -
H:\BACKUPS\Picasa Additions\Israel\test3\test.jpg VS H:\ASI\Travel & Photos\Israel\Israel - Photographs\2013\083113\כנס במכון פוליס - מקורות האלפאבית\IMG_1555.tif
The one from the left(test.jpg - short English-only folder path), works fine and the caption is written and recognized properly by Picasa
The right one (IMG_1555.tif heb. chars. long path) command line operation is completed successfully like the above (irfanview recognizes caption), but nothing is recognized by Picasa.
aside of the TiFF / JPG, I could not spot any meaningful difference, so I tried it on another tif image I copied to the simple folder.
The same problem occurred - command is performed successfuly, caption is written and recognized by irfanview, but nothing in Picasa...
Hmmm....errrr... bug in Picasa?
I'm just about to call it quits and go back to manual labor :'(
(For reference, attached are the ExifTool -a -G1 output for both files)
Too many things changed between these files to say what caused the problem.
What happens if you write a caption to the problem file with Picasa, then look at the differences in the exiftool output before and after. You should be able to narrow this down to a single change that causes the Picasa problem.
- Phil
Attached are 2 output txt files from the ExtifTool -a -g1 command - Before running anything on a (new) test file, and after running the command via Picasa.
The difference between the output is obviously the XMP and IPTC sections which were added upon running the batch command:
---- XMP-x ----
XMP Toolkit : Image::ExifTool 10.07
---- XMP-dc ----
Description : test3
---- IPTC ----
Coded Character Set : UTF8
Envelope Record Version : 4
Caption-Abstract : test3
Application Record Version : 4
How may we infer from this what might be the cause of the problem in Picasa?
Oh, OK. You added this with the batch file. That's not what I meant, but I have a question: Does Picasa recognize the caption in the "after" file? If not, use this as the start file and add the caption manually using Picasa. (I assume that Picasa has its own way of manually entering a caption.) Or do the minimum that is necessary to get Picasa to display a caption in this image. Then compare the exiftool outputs of the file that Picasa doesn't recognize the caption with the file that it does.
- Phil
I use the 'in-house' Picasa filename2caption button as this is my overall intention (and easiest for me in my current config).
Anyway, I've executed your idea. I chose to use the same actual text for the caption ('test3') for purposes of notepad++ compare func.
The before and after match! (PSA)
I reckon we may infer from this that the cause is something internal in Picasa.
Before I happily declare that Picasa is at fault -
Is there another comparison test you might suggest to further pinpoint the problem?
Those files are identical. I assume then that Picasa doesn't display the caption of either.
It does look like a Picasa problem, although we still haven't tracked down the specific cause. Adobe products once had a similar problem, and would refuse to display all metadata if any XMP timezone was "+00:00". I tracked this down easily by systematically changing each tag from a file that worked towards one that didn't. I think you could do the same thing here.
- Phil
The AfterPicasa_manual.txt from my previous post was generated after I manually edited the caption from the Picasa image editor and then saved it.
This is displayed properly by Picasa. Therefor I figured that this might be a specific Picasa problem.
Obviously I could bypass this by generating everything automatically by using the batch file,
isolate the ones that Picasa didn't display from some reason, and then just copy the XMP caption data itself onto the Picasa editor.
As this is just a smaller subgroup of images that require some manual intervention, I think that according to my needs I could live with it and leave it at that.
I might try browsing/asking around the Google Picasa forum for such an issue at a later time.
I just gotta get back to my original highest priority task at hand, which is sorting out all of my photos library.
So thanks for all the help with this issue :)
Quote from: asiniv on December 16, 2015, 07:40:05 AM
The AfterPicasa_manual.txt from my previous post was generated after I manually edited the caption from the Picasa image editor and then saved it.
This is displayed properly by Picasa.
But the metadata is identical to the one that doesn't display properly. Very interesting. Assuming this isn't a problem with a database somewhere else, there must be a difference between these two image files. If you could attach them here I will take a look.
- Phil
To be clearer - the last test trial I've performed involved a single image - first running the batch (within Picasa, by using the addon button which calls the ExifTool Batch Command),
and then by manually editing the caption.
The former fails to show-up in Picasa, the latter does.
As the aforementioned image is a large tif file, I could not add it here, so below is a link for the image from google photos
(though I'm not sure what can be inferred from a standard single tif Image uploaded to google photos, in relation to the discussed problem)
https://goo.gl/photos/B2yDEKojmiWuTxT5A (https://goo.gl/photos/B2yDEKojmiWuTxT5A)
Please note that you might have to manually clear the XMP caption if you intend on 'playing around with it'.
Your assistance is greatly appreciated!
BTW, it's also worth mentioning that Picasa DB management is not so robust and I personally experience many difficulties with it.
For reference you may view my other Picasa-related problems:
https://groups.google.com/a/googleproductforums.com/d/msgid/picasa/210b38b7-cb16-43c1-850b-07318dcdc738%40googleproductforums.com?utm_medium=email&utm_source=footer (https://groups.google.com/a/googleproductforums.com/d/msgid/picasa/210b38b7-cb16-43c1-850b-07318dcdc738%40googleproductforums.com?utm_medium=email&utm_source=footer)
https://groups.google.com/a/googleproductforums.com/d/msgid/picasa/9f654be6-10fa-497c-836b-e44f6caad3b4%40googleproductforums.com?utm_medium=email&utm_source=footer (https://groups.google.com/a/googleproductforums.com/d/msgid/picasa/9f654be6-10fa-497c-836b-e44f6caad3b4%40googleproductforums.com?utm_medium=email&utm_source=footer)
OK. I don't think I can help much more at this point since I don't want to get into running Picasa. All indications point to a Picasa quirk.
- Phil