1

I've found an AppleScript online which trims the first characters from a FILENAME, however, it does not seem to work on FOLDERS.

How could this be modified to rename folder names?

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 7 thru -1 of filename) as string)
    end tell
end repeat

Thank You!

  • Must this solution be apple script? I can make a bash script for this in a jiffy if that's acceptable – Alexander - Reinstate Monica Apr 27 '14 at 2:20
1

It's easy to trim the first six characters using Namechanger.

I apologize if you specifically need to use AppleScript, but Namechanger is a useful app for renaming files & folders. It has treated me well.

I hope this helps!

| improve this answer | |
1

This applies to the files selected in Finder and works with both folders and regular files:

tell application "Finder"
    repeat with f in (get selection)
        set name of f to (text 7 thru -1 of (get name of f))
    end repeat
end tell

You could also run a command like this in Terminal:

cd ~/containing/folder;for f in *;do mv "$f" "${f:6}";done
| improve this answer | |
0

Try:

set whichFolder to choose folder with multiple selections allowed
repeat with aFolder in whichFolder
    tell application "Finder"
        set folderName to name of aFolder
        set name of aFolder to (text 7 thru -1 of folderName)
    end tell
end repeat
| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .