Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Cybbe

macrumors 6502
Original poster
Sep 15, 2004
374
236
I am trying to create a simple Automator service to quickly change metadata on photos. I would like to be able to select x amount of files, run the service, and get a popup that asks for the f-number I want to change to:

At the moment this is set up to grab selected files in finder, and run the following terminal command:


exiftool -FNumber="1.8" -overwrite_original_in_place "$@"

pfAI8.png


(exiftool us an application used to edit metadata)

This command works, but the FNumber is hardcoded to 1.8. I would like to be able to dynamically specify the f-number via the "Ask for text" command. However, I don't know how I can ask for text and use the selected files as inputs at the same time. Does anyone know how these variables should be defined, and how they can be passed to a shell script?
 
Applescript

Standalone script :

Code:
set these_files to (choose file with prompt "Pick the files to process:" with multiple selections allowed without invisibles)
display dialog "Set your FNumber" default answer "\"1.8\"" buttons {"Cancel", "Ok"} default button 2
copy the result as list to {text_returned, button_pressed}
set the_FNumber to text_returned
repeat with i from 1 to number of items in these_files
	set this_item to item i of these_files
	-- insert actions here
	set this_item to quoted form of POSIX path of this_item
	try
		do shell script "exiftool -FNumber=" & the_FNumber & space & "-overwrite_original_in_place" & space & this_item
	on error errMsg number errNumber
		display alert errMsg message errNumber
	end try
end repeat

Automator Run Applescript action :

Code:
on run {input, parameters}
	(* Your script goes here *)
	display dialog "Set your FNumber" default answer "\"1.8\"" buttons {"Cancel", "Ok"} default button 2
	copy the result as list to {text_returned, button_pressed}
	set the_FNumber to text_returned
	repeat with i from 1 to number of items of input
		set this_item to item i of input
		-- insert actions here
		set this_item to quoted form of POSIX path of this_item
	try
		do shell script "exiftool -FNumber=" & the_FNumber & space & "-overwrite_original_in_place" & space & this_item
	on error errMsg number errNumber
		display alert errMsg message errNumber
	end try
	end repeat
	return input
end run
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.