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

alexk403

macrumors member
Original poster
Jul 24, 2012
59
1
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.

Code:
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

macrumors 6502a
May 29, 2011
578
226
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.