Get first item in list

Discussion in 'Mac Programming' started by vloryan, Oct 6, 2014.

  1. vloryan macrumors member

    Joined:
    Jan 11, 2014
    #1
    Guys,

    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!
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    The "Run AppleScript" action in Automator gives you this prototype handler:
    Code:
    on run {input, parameters}
    	
    	(* Your script goes here *)
    	
    	return input
    end run
    Read the explanation of this handler here:
    https://developer.apple.com/library...lAppleScript/WritingScript/WritingScript.html

    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.
     
  3. gujamin macrumors member

    Joined:
    Aug 6, 2002
    Location:
    Atlanta
    #3
    Probably a bit late, but I created an automator action to pick the first or last item from a list of items.
     

    Attached Files:

Share This Page