Mac Get first item in list


macrumors member
Original poster
Jan 11, 2014

this is probably very simple for all of you. I don't get it to work. I simply want to pass one PDF file only (not more than 1) withing the folder xpdf (on my desktop) to the next Automator action. Any idea how to do this with Applescript?

Thank you very much!


Staff member
Aug 9, 2009
The "Run AppleScript" action in Automator gives you this prototype handler:
on run {input, parameters}
	(* Your script goes here *)
	return input
end run
Read the explanation of this handler here:

Important point: 'input' is usually a list. So if the previous Automator action produces a list of PDF files, you want to output only the first item in that list.

So in AppleScript, knowing that you're given a list, write code that returns the first item in that list.

You should also show each Automator action's results, to confirm the output of the previous action is a list, and the result of the AppleScript action is a list or the single first item.
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.