I'm trying to do the following in an Automator workflow:
- Ask for Finder items from folder A
- In folder A, add a suffix to the file names
- Copy them to folder B
- In folder B, with an AppleScript, split the file name by a delimiter and then rename the file with the second half of the text split
- In folder B, add a prefix to the file names
- In folder B, add a suffix to the file names
Here is a sample of the file names I'm trying to rename:
- a new file$SG789.jpg
- file_2$123-456.jpg
- file_name$LG123.jpg
- this_file$558-432.jpg
The delimiter I'm splitting by is the "$" dollar sign to create the following new files:
- SG789.jpg
- 123-456.jpg
- LG123.jpg
- 558-432.jpg
These are the file name formats I'd like for the automator to continue processing.
Thanks to another user, I was able to get this far. However, my workflow is failing at step 5. I'm getting the following warning:
The action "Rename Finder Items: Add Text" was not supplied with the required data.
Here is the workflow setup in Automator:
With the AppleScript below:
on run {input, parameters}
try
set AppleScript's text item delimiters to "$"
set output to {}
repeat with anItem in input
set the end of output to text item 2 of (anItem as text)
end repeat
set AppleScript's text item delimiters to {}
return output
on error eStr number eNum
display dialog eStr & " number " & eNum buttons {"OK"} ¬
default button 1 with icon caution
set AppleScript's text item delimiters to {}
return
end try
end run
I thought by returning output, the next workflow would pick up and continue with the required changes. I'm seeing that is not the case.
How do I return my output so that the next workflow item can use it and continue with the file renaming?
(anItem as text)
.a new file$SG789.jpg
toSG789.jpg
.