31 Responses to “ExifTool and the Automator”

  1. Graham Parker says:

    This is very interesting info just what I need especially as I have just got a lensbaby Thank you
    One question if you don’t mind its a bit of a dumb one sorry
    Where can I get a pop up window like yours showing more info
    Thanks again
    Graham

  2. Klaus Messlinger says:

    Hi Graham,

    in Preview, just press Cmd+i while an image is open or use the menu (under “tools” you will find the “show information” entry).

    Hope that answers your question.

    Klaus

  3. Laurent says:

    Hi,
    You have done a fantastic tool, I no nothing about scripting, but your example is exactly what I was looking for, I’m a photograph, and I use a lot of manuals lenses, and I was looking for a loooooong time your trick of the “Write Lens Make And Aperture”
    Will it be possible to add a dialog box with text input fields like this :
    Lens : ………
    Focal length : ………
    Aperture : ……….

    and then the program write in the EXIF the value entered before !
    like this, you don’t have to create a Automator droplet for each combinaison of Lens/Aperture used

    can you tell me how to add such feature in the automator script ?
    Thank you very much for your work

    Best regards
    Laurent

  4. Klaus Messlinger says:

    Hi Laurent,

    thank you for your comment. Unfortunately, I do not know enough about Apple Script to help you out. As a matter of fact, I would be glad if someone came up with a solution to this, as it would be quite useful for most of the other ExifTool operations described in my blog (e.g. to set timezones).

    Any contributions are greatly appreciated!

    Klaus

  5. Laurent says:

    Hi,
    well after looking a bit, I found a great way, not perfect, but here it is :

    After loading the file, ask Automator to do an Applescript script :

    on run {input, parameters}
    set r to text returned of (display dialog “Lens parameter :” default answer “{\”Lens\”,\”Focal\”,\”Aperture\”}”)
    set r to run script r
    return r & input
    end run

    Than the Shell script :
    var1=”$1″
    var2=”$2″
    var3=”$3″
    shift 3
    for f in “$@”
    do
    exiftool -overwrite_original -Lens=”$var1″ -FocalLength=”$var2″ -ApertureValue=”$var3″ -FNumber=”$var3″ “$f”
    done

    That’s all

    Great no !!

  6. Sebastian says:

    Hi

    You have a nice walkthrough here, though I keep finding myself stuck. I’m trying to add the lens type, and have done what you were doing with the lensbaby, but simply missing the focal length and aperture parts out. In the run script shell itself I’m using:

    for f in “$@”
    do
    exiftool -overwrite_original -Lens=’70.0-300.0 mm f/4.5-5.6′ “$f”
    done

    The automator runs fine, but there is no change in the EXIF data. Is it blindly obvious what I’ve done wrong?

    Any help would be brilliant!
    Seb

  7. Sebastian says:

    Please ignore the previous comment, embarrassingly I had failed to change the pass input to ‘as argument’. A ‘nice’ guide has become a ‘wonderful’ guide :D.

    Many thanks!

  8. [...] wyżej napisał – jakiś EXIF-Tool + Automator. Poczytaj, może znajdziesz jakieś ciekawe info ExifTool and the Automator | studio.messlinger.com Komputer:  MacBook Pro 15.4-inch 2,4 GHz Telefon:  iPhone 3G 8GB -> Kanał [...]

  9. Alison_W says:

    Hi all,
    I would like to extract and create XMP files from DNG using Automator and exiftool. I have never used either tool so I am a totally new to this. I have found on the exiftool site some command lines that I think should work but I don’t know enough to string it all together. http://www.sno.phy.queensu.ca/~phil/exiftool/metafiles.html
    Does anyone have any suggestions?
    Thanks,
    Alison

  10. Klaus Messlinger says:

    Hi Alison,

    you have hit the right page with that link: you’ll find the commands you’ll need there.

    Follow the instructions above for setting up ExifTool and how to create Automator actions and then insert the command line from Phil’s documentation like this:

    for f in "$@"
    do
    <YOUR COMMAND LINE GOES HERE> "$f"
    done

    That’s all, really. Try to run your actions on copies of your images first, to avoid accidentally erasing metadata.

    If you want to run more than one command on your files, you may either create another Automator action or add the line into the above statement like this:

    for f in "$@"
    do
    <YOUR COMMAND LINE GOES HERE> "$f"
    <YOUR 2ND COMMAND LINE GOES HERE> "$f"
    <YOUR 3RD COMMAND LINE GOES HERE> "$f"
    done

    Have fun,
    Klaus

  11. Alison_W says:

    Hi Klaus, I must be doing something wrong as I have, within the examples you have given above, tried almost all the commands from that one web page and I don’t get any .xmp sidecar files. I have even tried your Read All Metadata above to get a text file and I get zippo. What I’m doing:
    1. Copied all adjusted DNG files to a folder on my desk top.
    2. Running Automator 2.0.4, OS X 10.5.8.
    3. Ask for Finder Items, start at: Folder On Desktop, Type: files, Yes allow Multiple.
    4. Run Shell Script, Shell: /bin/bash, Pass input: to stdin
    for f in “$@”
    do
    exiftool -n -g1 -w %d%f_tags.txt “$f”
    done

    When I run it I get the chime its done and not error. But I get no text file in the folder where I have the DNG files.

    I’m sure there is something really simple I’m missing.

    Thanks for the help.
    Alison

  12. Klaus Messlinger says:

    Hi Alison,

    I guess I made a mistake in my documentary screenshots (part of them was documentation-only and not taken from the productive scripts I am using):

    Please change “Pass input” from “to stdin” to “as arguments”.

    Sorry for the troubles this has caused.

    Klaus

  13. Alison_W says:

    Hi Klaus,
    No worries. This change did the trick. This is going to save me a ton of time going forward. Thanks so very much for posting this info and helping me with my little problem.
    Best regards,
    Alison

  14. http://www.panoramio.com/user/823582
    http://gallery.me.com/rdsck

    Just coming back from a 4X4 expedition in Bolivia. I noticed that my photos were positioned on the wrong place in Google. Then , in Panoramio forum, I heard that this is a well know Panoramio “mistake”.
    I found your site, and for the first time of my life, I opened Automator :-)))

    Many thanks for your time, great work ( and compassion ! )

    Kind regards from North Chile richard

  15. Hans van Turnhout says:

    This looks very promising. I have spent the better part of last night trying to create an action that will replace lost exif data in CS5 tampered files with the original exif data from the corresponding nef. I have all the arguments that I need to input (everything works if entered directly in the command line in the Terminal. The problem I have with the automator is that I need to input SourceDirectory “in the middle of the script” as well as TargetDirectory at the end of the script, i.e. I have .. fixed syntax + “INPUT1″ + fixed syntax + “INPUT2″. Is this possible, i.e. how do I get the script to read, ask for and accept INPUT1, read, ask for and accept INPUT2 and the execute?

    Regards

    Hans

  16. Hans van Turnhout says:

    I eventually got it right. Works like charm!

    //Hans

  17. Klaus Messlinger says:

    Hi Hans,

    thanks for your contribution. Maybe you can share the solution you found?

    Thanks,
    Klaus

  18. Hans van Turnhout says:

    Hi,

    Of course I can and if you like I can upload or send you the automator scripts so that they can be used and/or tweaked by you or others. I have three different scripts, one for replacing exif data in files in the same directory, two for replacing exif data where the source and target files are in different directories. I guess that the two latter could be combined into one but I haven’t yet tried that. The syntax in the same and different directory scripts are somewhat different.

    I tried to take a screenshoot and paste into this message but failed so I will try to give a step by step instruction.

    Drag two “Ask for Finder items” to the right hand side of the Automator dock

    I choose to have the program start at Desktop (but I guess the starting point can be whatever you like), set the type to folders and thick the box Allow Multiple Selection.

    Drag “run Shell Script” to the right hand side of the Automator dock.

    Set pass input As arguments and then have the “display” in the Shell Sscript text box read as follows:

    for f in “$@”
    do
    exiftool -tagsfromfile “$1″/%8f.nef -exif:all -ext tif “$2″
    done

    As a last item I dragged “Show Growl Notification” to the right hand side of the Automator dock.

    The syntax %8f means that files are picked based on the eight first characters and this might come in handy if edited files have been named with additional info such as “edited”. If you omit the “8″ the filenames need to match (except for the extension). What made me struggle with the Automator was that it took several hours before I realized that I had to put in numbers (1 and 2) instead of “f” in order to have the user input information passed to right place but I guess this is what happens when you have no real idea on what you are doing.

    I have also tried to make a script that deletes the resulting “original” but have not yet succeeded. The problem I have is that when the script has run you need to confirm deletion and I haven’t found a way to have this included.

    Regards

    Hans

  19. Karl says:

    I’ve downloaded and began playing with exiftool on my Mac, via the Automator. I suspect what I am trying to do is possible, but I am failing! (perhaps it’s impossible!) What I am trying to do is: Extract the file name, date stamp, and time stamp from each video in a folder of AVI files, and drop these into an excel spreadsheet, with each row of the spreadsheet being the data extracted from each file.

    I am working with Wildlife camera-trap images and video files, and part of the data-gathering exercise is to know when (date and time) an animal was photographed – so I am working with 1000s of files each month, and currently have to manually enter date and time for each image into the excel spreadsheet.

    Any help greatly appreciated!!

  20. Klaus Messlinger says:

    Hi Karl,

    it is probably best if you post your question right at the source: Phil Harvey’s ExifTool forum.

    If you search for “avi” you will already find lots of useful information. And Phil puts a lot of effort into answering new questions personally, so don’t be afraid to ask.

    Best regards,
    Klaus

  21. Klaus Messlinger says:

    PS: You will find the available options and commands in Phil’s Application Documentation.

  22. Karl says:

    Thanks Klaus!

  23. Pieter says:

    Hi Klaus,

    Excellent posting! Thanks a lot!

    ExifTool is a great tool but indeed unfortunately doesn’t come with a GUI for us Maccers.

    I’ve made a Folder Action using AppleScript in the past to have a folder on my Desktop on which I can drag&drop images e.g. from a browser window that will then instantly show a complete listing of the EXIF info. There are of course various browser plugins that do more or less the same, but none of these provide the depth of information that ExifTool provides (such as lens used).

    The AppleScript can be found here:
    http://www.onemorething.nl/community/topic/exiftool-applescript
    (Explanation is in Dutch…)

    Regards,
    Pieter.

  24. [...] # of fingers each time I switch to a different lens). Here is the link to get you started with an overview of what Exiftool and Automator can do. And here is the link to a script written by user "Fokalfissur" on the L-Camera Forum that puts it [...]

  25. Anthony says:

    I had a question. If i wanted to specify the ‘Date Created’ date how would I alter the code below for me to input the date I want to be written to the file?

    for f in “$@”
    do
    exiftool -overwrite_original ‘-IPTC:DateCreated<EXIF:CreateDate' "$f"
    done

  26. Klaus Messlinger says:

    Hello Anthony,

    just refer to Phil Harvey’s detailled manual for all sorts of examples.

    Klaus

  27. Nuurs says:

    Hey how are you?!
    First thank you for this post it was very easy to follow for a non code oriented person like me.
    I’m a photographer and I use a Rokinon 8mm lens (a manual lens) for my panoramic work and I need to add the f/ stop value and focal length and lens brand just like you did in your example, I’ve used your script and just changed the values there, but I get the “focal length wright”, but not the aperture value or the f/ stop, instead I get wrong values.
    I want to set f/8 “aperture”, Rokinon 8mm lens “name of the lens” and 0.5 as “focusing distance”.

    Example I’ve used:

    for f in “$@”
    do
    exiftool -overwrite_original -Lens=’Rokinon Fisheye 8mm F3.5-22′ -ApertureValue=’8′ -FocalLength=’0.5′ “$f”
    done

    What I’m doing wrong, notice that the script do it’s work without errors and I have the Phill’s EXIF tool installed without problems, but when read the Exif in Preview, the name of the lens is ok, ApertureValue is ok, FocalLength is ok, but where it say FNumber is 0.
    Thank you.
    Nuurs

  28. Klaus Messlinger says:

    Hello Nuurs,

    your script should be slightly adapted:

    for f in “$@”
    do
    exiftool -overwrite_original -Lens=’Rokinon Fisheye 8mm F3.5-22′ -ApertureValue=’8′ -FNumber=’8′ -FocalLength=’8′ -SubjectDistance=’50/100′ “$f”
    done

    “ApertureValue” and “FNumber” are both indicating your aperture (f-stop). Setting both values may increase your chances to correctly read them in your favourite imaging app.

    “FocalLength” is your focal length, i.e. 8mm. It is not the focusing distance!

    You will have to add the “SubjectDistance” tag in order to write your focusing distance. The value is given in meters and entered as a fraction (numerator and denominator). In the example above, the distance would be 0.5 m.

    Hope this was helpful for you!

    Klaus

  29. Russ says:

    Thank you! I played around with automator a couple of times in the past but your post here has now made it clear how to use it. I found exiftool thanks to graphicconverter and was very sorry there was no gui for it. This post has made it possible for me to use it and is almost as good as a gui. I had thousands of pictures I had edited, moved, copied, renamed, etc. and had so many duplicates I couldn’t count them. I also had lost the exif data on many and many were scans of old photos. Because of the way iphoto organizes, I really wanted to get valid dates into exif on all the pics and to get rid of all the duplicates and get back to the originals on the ones that had them. I also discovered photos with dates off because the camera dates weren’t set. I had been working on this project for 3 or 4 weeks (and probably making maters worse) before I found your post. Just wanted to say thank you again.

    For anyone else who may need to separate files with exif data from those without here is a quick way to do it

    for f in “$@”
    do

    exiftool ‘-Directory<DateTimeOriginal' -d Has_Exif "$f"
    done

    All the files with exif date will be moved to directory Has_Exif and those with out will stay where they were. (you may have to look for the directory. For some reason mine always ends up back in my user directory rather than as sub from where I started. )

    Now I can use graphic converter to find all the dups and not worry about deleting the copy with the exif data by mistake.

  30. GayanB says:

    Hello
    I am using the Apple automator workflow for Export EXIF data from Aperture. Unfortunately it doesn’t seem to export Lens Model info, everything else I need is there. I’ve admired your advice above and hoped perhaps you’d have some advice on how to add this important and missing piece of info for me?

    Thank you!

  31. Klaus Messlinger says:

    Hello GayanB,

    if you use the statement

    exiftool -n -g1 -w %d%f_tags.txt “$f”

    as described above under “Reading All Metadata”, the lens model gets exported, too.

    However, the information that is exported depends on the metadata category (Exif, IPTC, XMP, Canon etc.). For one of my shots I find in the EXIF section only:

    Lens Info : 24 105 undef undef

    In the Canon section, the entry is more specific:

    Lens Model : EF24-105mm f/4L IS USM

    If you want do dig deeper in the possibilities of exporting certain details of metadata, I suggest you look into the ExifTool examples page:

    http://owl.phy.queensu.ca/~phil/exiftool/exiftool_pod.html

    Best,
    Klaus

Leave a Reply