PDA

View Full Version : AppleScript inside Automator not working




alexk403
Jul 21, 2013, 03:44 PM
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



Red Menace
Jul 21, 2013, 10:09 PM
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.