Let me preface this by stating I have absolutely no idea what I'm doing in this arena, but I'm in need of a little help here.
I need to take filenames like this: amwed_0402c-slug~1-cp.jpg
And reduce them to slug~1.jpg
That is, I need to remove the first 12 and last 3 characters. The characters will frequently be different, but they will always be the first 12 and last three (before the file extension).
Anyway, I need to be able to execute this using Automator on the Mac so I can incorporate it into some photoshop actions.
Can anyone tell me how to do this? Any help would be much appreciated.
file=amwed_0402c-slug~1-cp.jpg
## Save the extension
ext=${file##*.}
## Extract the name without the extension
name=${file%.*}
## Remove the first 12 characters from the name
name=${name#????????????}
## Remove the last three characters
name=${name%???}
## Put the new filename together
newfile=$name.$ext