Monday, January 7, 2008

Picasa: Adding File Names to Caption

Update of this post is available at http://sandyiit.blogspot.com/2008/10/picasa-adding-file-names-to-caption.html

I used to save my pictures in photos@yahoo then moved to flickr. Flickr was good but had a limit of 200 pics per account. So had to move on to the google belt and started using picasa. There was 1 GB up for grabs so I started uploading my pictures to it.

I faced a problem. Normally when I transferred my pictures from my camera to my laptop, I got names like Picture 001.jpg, Picture 002.jpg. So I renamed them to names like 001. The start.jpg which conveyed more information and added to its memory value. Then I uploaded them to picasa to see that none to the names appear in there. Picasa uses IPTC tags to display captions.

Searching in the net, I found the tag was Iptc.Application2.Caption and this post provides nice information to set the captions equal to your filenames but the script

FOR %%c in (*.jpg) DO exiv2 -k -M"add Iptc.Application2.Caption %%c" "%%c"

has a issue. It takes filenames hence appends the extension .JPG to the caption too. Next it tries to add the IPTC tag which if already set, new caption can't be added. We need to force it or simply overwrite it. So I changed the script to

FOR %%c in (*.jpg) DO exiv2 -k -M"set Iptc.Application2.Caption %%~nc" "%%c"

This now sets hence overwrites the Caption tag and also takes the filename without the extension as the caption and thats what I wanted.

P.S: I got a comment:

Barun said...
Sonique/ Sandeep- I tried running the command given by sunil25125 by extracting exiv2-o.18 and making the nmtocap.dat, both in the same directory as my jpg files. But when I double click on the .dat file, I get following errors for each file:
Failed to Open the File

Any way out?

Thanks


And the answer is.

Windows shell might see some problems with the above script specifically the variable declared as %%c. Please try %c is that case specially when you get "Failed to Open the File" . So the script for you will be:

FOR %c in (*.jpg) DO exiv2.exe -k -M"set Iptc.Application2.Caption %~nc" "%c"

10 comments:

sonique1981 said...

hey man, thanks a lot for your post! i was fighting with the extension in caption issue and only you helped me to sort it out.
Actually what you can also do is that the EXIV2 file you put into program files directory so that you dont have to copy it all the time and also the batch file (i call it nmtocap.bat) you put in \windows\system directory so that you can write it in any directory and it sees it.
The text i'm now using is
FOR %%c in (*.jpg) DO "c:\program files\exiv\exiv2" -k -M"set Iptc.Application2.Caption %%~nc" "%%c"
thanks again, man!

Adria & Michael Gratiot said...

Awesome! I also don't like the file extension to show in the comments! I'll be updating 2 years worth of pictures with this information. They currently don't have any comments so I did not use Picasa web albums because it was tedious and easier to edit the file names for my records and another website. THANKS!

Peter said...

Thanks for the addition!

Do you know of a way to make it go through sub directories, or do I need to copy the script and program to each directory along the way.

Isaac Koi - New Uploads said...

Hi, Many thanks for posting this information. It really helped overcome the caption issue I was having on Picasa (which had almost made me move to a different photo hosting website...). All the best, Isaac

metcas said...

Hi Thanks for the tips I have made a slight change and added the path to the exiv2 files
FOR %%c in (*.jpg) DO "C:\Program Files\exiv2utils\exiv2" -k -M"set Iptc.Application2.Caption %%~nc" "%%c"

Cheers
Steve

AEL said...

Hey Thanks for the great Tip!

Sandeep Kumar said...

You are welcome

Unknown said...

Sonique/ Sandeep- I tried running the command given by sunil25125 by extracting exiv2-o.18 and making the nmtocap.dat, both in the same directory as my jpg files. But when I double click on the .dat file, I get following errors for each file:
Failed to Open the File

Any way out?

Thanks

Sandeep Kumar said...

Barun : Rename the file as .bat instead of .dat. That should help you out.

Unknown said...

thank you!!!