Go Back   The macosxhints Forums > OS X Help Requests > AppleScript



Reply
 
Thread Tools Rate Thread Display Modes
Old 03-07-2013, 07:38 PM   #1
Mark2000
Triple-A Player
 
Join Date: Nov 2006
Posts: 102
Pass variables to exiftool script

Hi! I take a lot of film photos and I like to add the camera info to the image files I scan with Exiftool - a command line tool.

Here's what I'd like to do to make life easier: I would be great if I could select certain files in the finder and run a finder service that would ask me to fill in certain variables before running. For instance:

exiftool -make="$1" -model="$2" -focallength="$3" -iso="$4" [files]

Where "$n" are the variables I'd like to asked to fill in each time and [files] is the files I would select. Possible?
Mark2000 is offline   Reply With Quote
Old 03-07-2013, 08:15 PM   #2
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 31,956
Easy enough to do if you don't mind a somewhat clunky user interface (e.g. one that asks you in 4 separate dialogs for the 4 variables.
See for example the following page (first Google result for: applescript prompt for input)
http://applescripting.wordpress.com/...y/applescript/
that shows an AppleScript that prompts for some text.

Once you have the values in your AppleScript, you can use 'do shell script' to invoke 'exiftool'

But you do realize that there are a bunch of existing GUI utilities that will do this for you. (Allow you to edit the EXIF info on image files)?
__________________
hayne.net/macosx.html
hayne is offline   Reply With Quote
Old 03-08-2013, 12:48 AM   #3
Mark2000
Triple-A Player
 
Join Date: Nov 2006
Posts: 102
If you know of any I'd love to here about them. There's only one GUI for exiftool on Mac and it doesn't do anything but GPS, make, model, and date. Everything else is on the app store, hasn't been updated in over a year, and costs $10.

If you could give me any more hints, I appreciate it. I'm a total noob with not actionscript experience.
Mark2000 is offline   Reply With Quote
Old 03-08-2013, 01:58 AM   #4
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 31,956
1) Hints for doing it with AppleScript (not "actionscript"):
- read lots of tutorials on AppleScript
- try the examples
- try modifying the AppleScripts you can find via Google

2) If it isn't worth $10 to get a dedicated tool for something that you seemingly do a lot, I have no further advice.
__________________
hayne.net/macosx.html
hayne is offline   Reply With Quote
Old 03-08-2013, 10:32 AM   #5
Mark2000
Triple-A Player
 
Join Date: Nov 2006
Posts: 102
hayne, as I explained, most of those tools are poorly updated, some don't work with the latest OS, and $10 is a lot to spend on something with no future support. You don't seem to have any specific suggestions for apps so I'm guessing you were just trying to make my needs seem stupid and pointless.

Second, thanks for directing me to the Googles. I've never used it before and it's great. Really what's the point of this place if the answers are everywhere else? Why do you moderate a place that is here to help people if you're just going to tell them to "Google it"? I could spend hours of my precious time doing tutorials in order to figure out what ends up being three lines of code or you could have just said "Sure that's easy, you do this". It would have taken the exact same number of keystrokes. Next time you come to a photography forum I'll be sure to give you the same advice.

For anyone interested, I did find the answer here: http://apple.stackexchange.com/quest...l-in-automator . Yeah, I googled it after many attempts at finding the right search terms. A google search is worthless if you're too much of a noob to know what you're looking for in the parlance of the topic. That's why human help sometimes actually matters.
Mark2000 is offline   Reply With Quote
Old 03-09-2013, 11:03 AM   #6
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 31,956
1) I already pointed you to one example of getting text input in post #2 (very similar to the example you linked to)

2) I was explaining how to become more proficient in AppleScript (tutorials, examples, etc). The point is that there is no royal road to expertise.

3) $10 for most people is worth it if you get something that is better than what you can create in AppleScript (or whatever) with some hours of effort.

4) Does Apple really offer apps on the App Store that don't work on the latest OS X version? That's surprising.
__________________
hayne.net/macosx.html
hayne is offline   Reply With Quote
Old 03-09-2013, 08:39 PM   #7
mark hunte
MVP
 
Join Date: Apr 2004
Location: Hello London Calling
Posts: 1,787
Seriously mate,

Whats with the attitude.

Haynes response was very helpful considering you basically listed a wish list and asked if it is possible.

He could have simply replied "Yes" and not given you any examples or advice.

The fact that he had no work from you on the Finder service to go on would mean if he did not just answer "Yes".
Then he or anyone else could only probably answer in three other ways.
  1. Point you to examples and give advice on how to get to the position of writing it your self.
  2. Writing it for you.
  3. Ask you what have you tried..


You should note that the people who get the most help are generally the people who help them selves.

In this I mean you did not post anything to show you had actually had a go at making your Finder service.

And I do not mean this as a put down but it seems to me you want some one to give you the answer by doing the work for you.


You will notice that the link you pointed to has an answer on it actually from me.
The OP there got help from me because they showed that they had tried to do some of the work their selves.


As for google terms a simple "how to make a Finder service os x" brings a good enough list with examples. You know what you want to do and looking using that as a search term in google bring exactly that. That is not rocket science Noob or not
__________________
MH.
mark hunte is offline   Reply With Quote
Old 03-31-2013, 10:05 PM   #8
sojourner
Major Leaguer
 
Join Date: Apr 2010
Posts: 339
I don't have exiftool installed on my system, so I'm going by the line you quoted in your original post. Noticed that you used double quotes in that line instead of single quotes. The script below uses single quotes. If that's a problem, let me know and we'll tweak the script.

Code:
set textButtonDefault to "Okay"
set textButtonCancel to "Cancel"

set listExifMetaTypes to {"make", "model", "focal length", "iso"}

set listImageFiles to choose file with prompt "Select file(s)" of type {"public.image"} default location (path to pictures folder from user domain as alias) with multiple selections allowed

set listImageFilesQuotedPosix to {}

repeat with aliasImageFile in listImageFiles
	set listImageFilesQuotedPosix to listImageFilesQuotedPosix & quoted form of (POSIX path of aliasImageFile)
end repeat

set AppleScript's text item delimiters to space
set stringImageFilesQuotedPosix to listImageFilesQuotedPosix as string
set AppleScript's text item delimiters to {""}

set listExifMetaData to {}

repeat with textExifMetaType in listExifMetaTypes
	set listExifMetaData to listExifMetaData & quoted form of (text returned of (display dialog "Enter" & space & textExifMetaType default answer "" buttons {textButtonCancel, textButtonDefault} default button textButtonDefault cancel button textButtonCancel with title "Enter Exif Data"))
end repeat

do shell script "exiftool" & space & "-make=" & item 1 of listExifMetaData & space & "-model=" & item 2 of listExifMetaData & space & "-focallength=" & item 3 of listExifMetaData & space & "-iso=" & item 4 of listExifMetaData & space & stringImageFilesQuotedPosix
__________________
see a problem; solve a problem.
sojourner is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 01:18 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.