AppleScript inside Automator not working

Discussion in 'Mac Programming' started by alexk403, Jul 21, 2013.

  1. alexk403 macrumors member

    Jul 24, 2012
    I have this exact code inside an automator "Run AppleScript" thing. The applescript works perfectly on its own but once I put it in the automator i get the same result i input into it (its supposed to remove the spaces). Any help is appreciated. Thanks in advance.

    on run {input, parameters}
    	set movieName to input
    	set needle to " "
    	set replacement to ""
    	search_replace(movieName, needle, replacement)
    end run
    on search_replace(movieName, needle, replacement)
    	set old_delimiters to AppleScript's text item delimiters
    	set AppleScript's text item delimiters to needle
    	set temp_list to every text item of movieName
    	set AppleScript's text item delimiters to replacement
    	set return_value to temp_list as text
    	set AppleScript's text item delimiters to old_delimiters
    	return return_value
    end search_replace
  2. Red Menace macrumors 6502

    Red Menace

    May 29, 2011
    Littleton, Colorado, USA
    The input to an Automator action is a list, even if it only contains a single item. The solution would be to repeat through the items of the input and process each one. Less ideal would be to coerce the input to text, or get the first item of the list.

Share This Page