How to trim the first 3 characters in file name with AppleScript

applescript

Is there a way to trim off the first 3 character of multiple file names? (or last 3 characters)

Best Answer

This code will do it for you:

set whichFile to choose file with multiple selections allowed
repeat with aFile in whichFile
    tell application "Finder"
        set filename to name of aFile
        set name of aFile to ((characters 4 thru -1 of filename) as string) --trim first 3
        --set name of whichFile to ((characters 1 thru -4 of filename) as string) --trim last 3
    end tell
end repeat

Note that stripping the last three will get rid of the extension. If that isn't what you want to happen, let me know in a comment.