I'm creating an automator script that copies files from one folder to another and then runs an AppleScript to rename the file by splitting via delimiter and resaving with the second item. For example, using file names of:
a new file$SG789.jpg
file_2$123-456.jpg
file_name$LG123.jpg
this_file$558-432.jpg
I'm trying to split the filename by the "$" dollar sign to create the following new files:
SG789.jpg
123-456.jpg
LG123.jpg
558-432.jpg
However, when I run the script, I get the following error:
The action “Run AppleScript” encountered an error. Can’t get item 2 of alias "Macintosh HD:Users:downloads:Archive:a new file$SG789-PROC.jpg".
This is the code I'm running in the Run AppleScript workflow:
	
	
	
		
What am I doing wrong?
	
		
			
		
		
	
				
			a new file$SG789.jpg
file_2$123-456.jpg
file_name$LG123.jpg
this_file$558-432.jpg
I'm trying to split the filename by the "$" dollar sign to create the following new files:
SG789.jpg
123-456.jpg
LG123.jpg
558-432.jpg
However, when I run the script, I get the following error:
The action “Run AppleScript” encountered an error. Can’t get item 2 of alias "Macintosh HD:Users:downloads:Archive:a new file$SG789-PROC.jpg".
This is the code I'm running in the Run AppleScript workflow:
		Code:
	
	on run {input, parameters}
    set AppleScript's text item delimiters to "$"
    repeat with anItem in input
        set fileName to item 2 of anItem
        return fileName
    end repeat
end runWhat am I doing wrong?
