ExifTool is a command line package that allows you to read and write EXIF data from image files.
CategoryShell CategoryImaging CategoryApplescript

Download the OSX installer diskimage from http://sno.phy.queensu.ca/~phil/exiftool/

The ExifTool command file gets installed at
/usr/bin/ExifTool

You then invoke ExifTool like this:
ExifTool -CreateDate ~/Desktop/Citroen/Citroen\ 1.jpg

which returns a string like:
Create Date         : 2006:05:06 10:19:47

For renaming files, you would need to use sed or some other parsing tool to extract the text you want and convert illegal characters to Finder compatible characters.

Once you have accomplished that, you would use the find command to round up all targeted files:
find $HOME'/Pictures' -name '*.jpg'
You could probably pipe all these commands together to execute in terminal in one fell swoop

Some commands possibly useful in understanding embedded tags:

ExifTool -ver
ExifTool --help
ExifTool test.jpg
ExifTool -a -G1 -s test.jpg
ExifTool -htmlDump test.jpg > test.html

Write an EXIF comment:
ExifTool -Comment='COMMENT' test.jpg

Read IPTC data fields:

ExifTool -IPTC:CodedCharacterSet test.jpg
ExifTool -IPTC:ApplicationRecordVersion test.jpg
ExifTool -IPTC:Caption-Abstract test.jpg
ExifTool -IPTC:Headline test.jpg
ExifTool -IPTC:ObjectName test.jpg
ExifTool -IPTC:FixtureIdentifier test.jpg
ExifTool -IPTC:Keywords test.jpg

Write IPTC data (note that the Caption includes a newline character, \n does not work):

ExifTool -IPTC:Caption-Abstract='Cap
tion' test.jpg
ExifTool -IPTC:Headline='Headline' test.jpg
ExifTool -IPTC:ObjectName='Title' test.jpg
ExifTool -IPTC:FixtureIdentifier='Event' test.jpg
ExifTool -IPTC:Keywords+='keyword' test.jpg

A simple Applescript that uses ExifTool might look like this:

tell application "Finder"
   set fileList to the selection
   repeat with loopVar in fileList
      set someURL to comment of loopVar
      set IPTCtitle to "test title"
      set IPTCtitle to do shell script "curl -s " & someURL & " | sed -n 's|.*<title>\\(.*\\)</title >.*|\\1|p'"
      set cmd to "ExifTool -IPTC:ObjectName=\"" & IPTCtitle & "\"" & space & quoted form of POSIX path of (loopVar as alias)
      tell application "Terminal"
         if not (exists window 1) then do script ""
         do script cmd in front window
      end tell
      delay 3
   end repeat
end tell

The above script gets the OSX Spotlight Comment of all selected files in a folder, which is the URL to an image page. It extracts the html title and writes it to the IPTC Title field inside the image file. The command line is run in Terminal so you can see the progress. The delay value just slows the events down trying to prevent collisions.

Smiley:

Computer/Shell/ExifTool (last edited 2010-01-29 22:57:42 by Gnarlodious)