ExifTool Forum

ExifTool => Developers => Topic started by: Bosque Bill on November 18, 2015, 12:18:37 PM

Title: Using exiftool with Automator in Yosemite
Post by: Bosque Bill on November 18, 2015, 12:18:37 PM
I successfully installed exiftool on my Mac running Yosemite.
I'm trying to build a Service using Automator to subtract an hour from selected photo files. I followed the example on Semiocity (link below).

My shell script is:

for f in "$@"
do
exiftool -overwrite_original -AllDates-=1 "$f"
done


If I run exiftool from terminal, it works fine; if I run from Automator, I get 'The action "Run Shell Script" encountered an error.' The system log shows: 'code validation failed in the process of getting signing information: Error Domain=NSOSStatusErrorDomain Code=-67062' Where 67062 equals 'a Code object is not signed error' and Automator terminates without running exiftool.

Am I doing something wrong? Is this part of the OS X security? And if so, is there a command or switch to include in the script to bypass this?

Thanks for your help.

Bill


referenced link: http://www.semiocity.com/batch-editing-exif-information-with-exiftools-and-apple-automator-a-case-study-on-the-pentax-k-5-camera-sigma-17-50-mm-f2-8-ex-dc-os-hsm-lens-combination/
Title: Re: Using exiftool with Automator in Yosemite
Post by: Phil Harvey on November 18, 2015, 12:35:06 PM
Hi Bill,

I think this is part of the OS X security.  Maybe reading this (https://developer.apple.com/library/ios/technotes/tn2318/_index.html) will help.  (I haven't read it myself.)

- Phil
Title: Re: Using exiftool with Automator in Yosemite
Post by: Bosque Bill on November 18, 2015, 12:46:35 PM
Quote from: Phil Harvey on November 18, 2015, 12:35:06 PM
I think this is part of the OS X security.  Maybe reading this (https://developer.apple.com/library/ios/technotes/tn2318/_index.html) will help.  (I haven't read it myself.)

Thanks, but this article seems to be for authors of Xcode apps to troubleshoot app signature errors, and not applicable to my issue that I can see, as I'm not the app author, just trying to run it from Automator.

I'm hoping some folks on here who are familiar with using Automator and exiftool can help.

Bill
Title: Re: Using exiftool with Automator in Yosemite
Post by: Phil Harvey on November 18, 2015, 12:54:42 PM
OK.  I see this:

> codesign -dvvv exiftool
exiftool: code object is not signed at all

> codesign -dvvv /bin/sh
Executable=/bin/sh
Identifier=com.apple.sh
Format=Mach-O thin (x86_64)
CodeDirectory v=20100 size=3141 flags=0x0(none) hashes=152+2 location=embedded
Hash type=sha1 size=20
CDHash=7b36bb7fe32cb65ea21980a761b8a363148501f2
Signature size=4097
Authority=Software Signing
Authority=Apple Code Signing Certification Authority
Authority=Apple Root CA
Info.plist=not bound
TeamIdentifier=not set
Sealed Resources=none
Internal requirements count=1 size=60


So exiftool is no signed (as expected), but other standard command-line binaries are.  This is likely the problem, although I can't understand why exiftool runs from the Terminal for you but not from the Automator.

Have you enabled apps from "Anywhere" in the Security settings (read here (http://www.theinstructional.com/guides/gatekeeper-fundamentals-part-1))?

- Phil
Title: Re: Using exiftool with Automator in Yosemite
Post by: Bosque Bill on November 18, 2015, 01:13:44 PM
Quote from: Phil Harvey on November 18, 2015, 12:54:42 PM
So exiftool is no signed (as expected), but other standard command-line binaries are.  This is likely the problem, although I can't understand why exiftool runs from the Terminal for you but not from the Automator.

Have you enabled apps from "Anywhere" in the Security settings (read here (http://www.theinstructional.com/guides/gatekeeper-fundamentals-part-1))?

- Phil

That "Anywhere" setting is just for downloading, doesn't affect execution (and yes, I did try this today.)

If I'm reading the system.log correctly (no guarantees) that same "code validation failed" warning is generated when I run from the Terminal, but the code does run and modify's my photo file as specified.

I just tried overwriting errors in the script using "|| true". It does suppress the error dialog box from appearing, but exiftool does not run and my file is unchanged.

I'm thinking I need a way to tell the OS to run the unsigned app anyway from Automator. There must be a way as apparently others are using Automator with exiftool. Right?

Thanks,
Bill
Title: Re: Using exiftool with Automator in Yosemite
Post by: Phil Harvey on November 18, 2015, 01:34:37 PM
Quote from: Bosque Bill on November 18, 2015, 01:13:44 PM
That "Anywhere" setting is just for downloading

No.  It affects running of downloaded apps.  (I agree that the Apple dialog is misleading.)

QuoteI'm thinking I need a way to tell the OS to run the unsigned app anyway from Automator. There must be a way as apparently others are using Automator with exiftool. Right?

Yes.  I did some quick Googling but didn't find any Automator-specific solutions.

Alternatively, I wonder if it is possible to sign exiftool without having to pay Apple for the pleasure.

- Phil
Title: Re: Using exiftool with Automator in Yosemite
Post by: Bosque Bill on November 18, 2015, 01:44:43 PM
Quote from: Phil Harvey on November 18, 2015, 01:34:37 PM
Quote from: Bosque Bill on November 18, 2015, 01:13:44 PM
That "Anywhere" setting is just for downloading

No.  It affects running of downloaded apps.  (I agree that the Apple dialog is misleading.)

Hmmm. I downloaded exiftool yesterday by option-clicking the package and telling the OS to go ahead and install it.

I later (today) changed the security setting to "Anywhere" and tried running the Automator script again and still got the error.

I'm wondering now if I should uninstall exiftool and then change my setting to "Anywhere" and then download and install again. Think that might work?

Bill
Title: Re: Using exiftool with Automator in Yosemite
Post by: Phil Harvey on November 18, 2015, 01:56:06 PM
Hi Bill,

I doubt that it will make a difference, but it is worth a try.  If you post your automator script I could try running it here to see if I have the same problem. (But it will be tomorrow because I'm about to head out for the day.)

- Phil
Title: Re: Using exiftool with Automator in Yosemite
Post by: Bosque Bill on November 18, 2015, 01:59:03 PM
Quote from: Phil Harvey on November 18, 2015, 01:56:06 PM
Hi Bill,

I doubt that it will make a difference, but it is worth a try.  If you post your automator script I could try running it here to see if I have the same problem. (But it will be tomorrow because I'm about to head out for the day.)

- Phil

You are right, that didn't work. I uninstalled exiftool per instructions and deleted the earlier app disc image. I changed my security setting to "Anywhere", re-downloaded exiftool disc image, and re-installed. Ran my Automator script and got the same error without exiftool modifying my file. Sigh.

I included my Automator script in my first post in this thread. And I need to get about my day, too.

Thanks for your help.

Bill
Title: Re: Using exiftool with Automator in Yosemite
Post by: Bosque Bill on November 19, 2015, 11:08:25 AM
After more research, and posting this question on the Apple forum, I'm wondering if I'm barking up the wrong tree.

I tried a couple things suggested in the Mac OS X Technologies forum, which didn't work either. But in doing so I spent more time looking at the system.log. There seem to be a significant number of those 67062 code validation errors which do not correspond in time to my running the Automator script. And today, those specific errors do not show up exactly when I'd expect them to (unlike their appearance yesterday), but a bit later in time. They may not be related.

The only for sure error in the log directly related to my Automator script is:
WorkflowServiceRunner[97309]: WorkflowServiceRunner received error running Workflow Service at /Users/[me]/Library/Services/EXIF Fall Back.workflow: The action "Run Shell Script" encountered an error.
(I've replaced my username with [me] in the above quoted message.)

This is my script:
for f in "$@"
do
exiftool -overwrite_original -AllDates-=1 "$f"
done


I've also tried:
for f in "$@"
do
/usr/local/bin/exiftool -overwrite_original -AllDates-=1 "$f"
done


In Automator I'm running Shell: /bin/bash   Pass input: to stdin
Title: Re: Using exiftool with Automator in Yosemite
Post by: Phil Harvey on November 19, 2015, 11:37:46 AM
Hi Bill,

If this is a bash script, I think your quotes are wrong.  Use standard double quotes around "$@" instead of the fancy ones you posted.  Like this:

for f in "$@"
do
/usr/local/bin/exiftool -overwrite_original -AllDates-=1 "$f"
done


Also, it is much simpler and more efficient to call ExifTool only once.  Drop the "for" loop and do this instead:

/usr/local/bin/exiftool -overwrite_original -AllDates-=1 "$@"

- Phil
Title: Re: Using exiftool with Automator in Yosemite
Post by: Bosque Bill on November 19, 2015, 12:02:23 PM
Gee, I thought I fixed those quotes before, but must have done another copy.

Sure enough, fixing the quotes stopped the script run error message, but now I'm left with the puzzle of why running the script in Automator does not change the EXIF times in my image file - I'm testing on a jpg on my desktop to keep it simple.

p.s., when I drop the 'for' loop and substitute your single-line suggestion, I get another script run error.
Title: Re: Using exiftool with Automator in Yosemite
Post by: Phil Harvey on November 19, 2015, 12:06:54 PM
The script I posted works as a bash script.  If you could give me step-by-step instructions of how you are running it I will see if I can reproduce your problem.

- Phil
Title: Re: Using exiftool with Automator in Yosemite
Post by: Bosque Bill on November 19, 2015, 12:12:54 PM
Quote from: Phil Harvey on November 19, 2015, 12:06:54 PM
The script I posted works as a bash script.  If you could give me step-by-step instructions of how you are running it I will see if I can reproduce your problem.

I'll attach my Automator screen capture. To run, I'm selecting the image file, right-clicking to bring up the context menu, then under Services I'm clicking my workflow "EXIF Fall Back". I get the confirmation prompt and click OK.

Title: Re: Using exiftool with Automator in Yosemite
Post by: Phil Harvey on November 19, 2015, 12:17:23 PM
It would really save me time if you could post your Automator script.

- Phil
Title: Re: Using exiftool with Automator in Yosemite
Post by: Bosque Bill on November 19, 2015, 12:24:08 PM
Quote from: Phil Harvey on November 19, 2015, 12:17:23 PM
It would really save me time if you could post your Automator script.
Oh, you mean the workflow file itself? OK, I'll attach it.
Title: Re: Using exiftool with Automator in Yosemite
Post by: Phil Harvey on November 19, 2015, 12:36:29 PM
There we go.

Try this.

I changed the "Pass input:" settings in your shell script from "to stdin" to "as arguments" and it fixed the problem.  Also, I got rid of your for loop.

Note that I have never done anything in Automator, so this problem was solved by trial and error at my end.

- Phil

Edit: Out of interest, I can also get it to work with "Pass input:" set to "to stdin" by adding "-@ -" to the exiftool command.  (So ExifTool reads arguments from stdin.)
Title: Re: Using exiftool with Automator in Yosemite
Post by: Bosque Bill on November 19, 2015, 06:07:48 PM
Outstanding! It works now for me, too - both methods.

Thanks so much, Phil. You may not have had much experience with Automator (neither have I, obviously), but you've had lots more experience with scripting, I'm sure.

As a small token of appreciation for your time, I've sent you a "cup of coffee" via your PayPal donation link.

Bill
Title: Re: Using exiftool with Automator in Yosemite
Post by: Phil Harvey on November 20, 2015, 07:44:03 AM
Thanks!  Glad to help.
Title: Re: Using exiftool with Automator in Yosemite
Post by: Bosque Bill on November 20, 2015, 10:43:21 AM
I've now created a "Spring Forward" Automator script to complement my "Fall Back" script. (Though I hope come spring I remember to adjust the time in my cameras before taking lots of photos!)

If anyone reading this uses Adobe Bridge, note that the program caches the EXIF data. When I tested my scripts on a couple CR2 files in Finder, the changes didn't show up in Bridge right away - I figured ExifTool worked, as I saw the tmp file being created and deleted in Finder. In the top menu in Bridge you can click Tools > Cache > Purge cache for [folder] to see the changes in the EXIF data.

[update: if you have the target folder open in Bridge when you modify the files with ExifTool, Bridge appears to update itself as the script works through the files and you can see your results. In my original test I did not have the folder open in Bridge and had to manually purge the folder cache; that's the opposite of what I'd expected.]

ExifTool is a super utility, that I hope I don't have to use too often ;-)  I'm going to spread the word to my photography friends.