Sunday, June 16, 2019

#1 2019-06-11 08:41:43 pm

snegaroff
Member
Registered: 2006-04-28
Posts: 6

do shell script error

Looking for help on why this works in the Terminal...

/usr/local/bin/exiftool -Orientation -n '/Users/greg/Pictures/Photos Library.photoslibrary/Masters/2007/Roll 344/DSC_0041.JPG'

...but the following throws up an error message in the Script Editor...

do shell script "/usr/local/bin/exiftool -Orientation -n '/Users/greg/Pictures/Photos Library.photoslibrary/Masters/2007/Roll 344/DSC_0041.JPG'"

I assume it has something to do with the fact that Photos Library is a package that requires "Show Package Contents" to show the full path in the Finder.

Any assistance is appreciated. Thanks.

Offline

 

#2 2019-06-11 09:36:44 pm

KniazidisR
Member
Registered: 2019-03-03
Posts: 145

Re: do shell script error

Probably you need escape internal quotes (which is inside external quotes) with AppleScript's way (\") instead of command line's way ('). Always. Try this:

Applescript:


do shell script "/usr/local/bin/exiftool -Orientation -n \"/Users/greg/Pictures/Photos Library.photoslibrary/Masters/2007/Roll 344/DSC_0041.JPG\""

Last edited by KniazidisR (2019-06-11 09:43:44 pm)


macOS Mojave -- version 10.14.4
Safari -- version 12.1

Offline

 

#3 2019-06-12 07:44:51 am

peavine
Member
From:: Prescott, Arizona
Registered: 2018-09-04
Posts: 79

Re: do shell script error

FWIW, another way to deal with quoting is:

Applescript:


do shell script "/usr/local/bin/exiftool -Orientation -n " & quoted form of "/Users/greg/Pictures/Photos Library.photoslibrary/Masters/2007/Roll 344/DSC_0041.JPG"

Or, perhaps to make things a bit clearer:

Applescript:


set myFile to "/Users/greg/Pictures/Photos Library.photoslibrary/Masters/2007/Roll 344/DSC_0041.JPG"

do shell script "/usr/local/bin/exiftool -Orientation -n " & quoted form of myFile

This won't address the package issue mentioned by the OP (if there is an issue).

Last edited by peavine (2019-06-12 07:04:09 pm)

Offline

 

#4 2019-06-12 09:02:16 pm

snegaroff
Member
Registered: 2006-04-28
Posts: 6

Re: do shell script error

Thanks all for the replies. I tried them all, but unfortunately, they result in "Error: Error opening file."

Because this exact syntax works for other visible files, I'm thinking it must be something with the unique status of the package contents of the "Photos Library."

Offline

 

#5 2019-06-12 09:55:22 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5698

Re: do shell script error

snegaroff wrote:

Because this exact syntax works for other visible files, I'm thinking it must be something with the unique status of the package contents of the "Photos Library."



I don't think so. At least, it works for a Photo Library image here.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#6 2019-06-13 07:29:53 am

peavine
Member
From:: Prescott, Arizona
Registered: 2018-09-04
Posts: 79

Re: do shell script error

I created a "Photos Library" and placed one photo in it. I then ran the following in a terminal window:

/usr/local/bin/exiftool -Orientation -n "/Users/bob/Pictures/Photos Library.photoslibrary/Masters/2019/06/13/20190613-130451/Willlow Creek Snow.jpg"

This returned "Orientation 3".

I then ran the above command line in an AppleScript as follows

Applescript:

set myFile to "/Users/bob/Pictures/Photos Library.photoslibrary/Masters/2019/06/13/20190613-130451/Willlow Creek Snow.jpg"

do shell script "/usr/local/bin/exiftool -Orientation -n " & quoted form of myFile

This returned:

error "Error: Error opening file - /Users/bob/Pictures/Photos Library.photoslibrary/Masters/2019/06/13/20190613-130451/Willlow Creek Snow.jpg" number 1

I then placed the photo in a regular folder and ran the following in an Applescript:

Applescript:

set myFile to "/Volumes/Samsung SSD/Working/Willlow Creek Snow.jpg"

do shell script "/usr/local/bin/exiftool -Orientation -n " & quoted form of myFile

This returned "Orientation 3".

So, my experience is the same as the OP and I wonder what Shane is doing differently?

Offline

 

#7 2019-06-13 07:34:21 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5698

Re: do shell script error

peavine wrote:

I wonder what Shane is doing differently?



Not storing his photos in iCloud?


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#8 2019-06-13 07:38:25 am

peavine
Member
From:: Prescott, Arizona
Registered: 2018-09-04
Posts: 79

Re: do shell script error

iCloud is disabled on my computer. I'm running Mojave and version 11.21 of exiftool.

BTW I ran the following and it showed no files inside the photo package:

Applescript:

set myPhoto to (choose file with showing package contents)
set myFile to POSIX path of myPhoto
do shell script "/usr/local/bin/exiftool -Orientation -n " & quoted form of myFile

The files/folders in the photo package are visible in the Finder.

Last edited by peavine (2019-06-13 09:22:28 am)

Offline

 

#9 2019-06-13 08:43:52 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 3458

Re: do shell script error

Running 10.3.6 and using a local library (never used iCloud) exiftool version 11.51 returned correctly the wanted info : "Orientation                     : 1"

The code used was :

Applescript:

set leChemin to (path to pictures folder as text) & "Photos Library.photoslibrary:Masters:2015:10:10:20151010-200530:P1010002.JPG"
set myFile to POSIX path of leChemin
do shell script "/usr/local/bin/exiftool -Orientation -n " & quoted form of myFile

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) jeudi 13 juin 2019  16:43:45

Last edited by Yvan Koenig (2019-06-13 08:47:23 am)

Offline

 

#10 2019-06-13 09:39:02 am

peavine
Member
From:: Prescott, Arizona
Registered: 2018-09-04
Posts: 79

Re: do shell script error

Perhaps this is a Mojave permissions issue. I ran the following script as a standalone application, and, after prompting for permission to access my photos, the script ran correctly. The exact same script if run from within the script editor returned the error-opening-file message.

Applescript:

set myFile to "/Users/bob/Pictures/Photos Library.photoslibrary/Masters/2019/06/13/20190613-141651/Willlow Creek Snow.jpg"

set theOrientation to (do shell script "/usr/local/bin/exiftool -Orientation -n " & quoted form of myFile)

display dialog theOrientation

Edit 2019-06-15. The OP has not provided enough information to answer his/her original question with certainty but it appears the answer is 1) quoting in the AppleScript is not correct, and 2) Mojave permission is required by the AppleScript to access the OP's photos.

Last edited by peavine (Yesterday 06:49:45 pm)

Offline

 

#11 2019-06-13 05:08:02 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5698

Re: do shell script error

peavine wrote:

Perhaps this is a Mojave permissions issue.



Could be. I ran it from Script Debugger, and in Preferences -> Privacy -> Photos, Script Debugger appears and is checked.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)