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!
I'm not familiar with Alfred however as far as AppleScript and getting an Application Bundle's Icon's pathname is typically not hardcoded, so it's not like you can get its path with a single command. Additionally the value of CFBundleIconFile
can be with and without the .icns
extension, so when building the fully qualified pathname of the Application Bundle's Icon you'll need to take that into consideration as you write your code.
As an example, using the built-in /Applications/Calculator.app
the /Applications/Calculator.app/Contents/Info.plist
shows that the Icon file is "Calculator.icns" but doesn't give the path, although it will usually be within the Resources folder within the Application Bundle and in this case it's, /Applications/Calculator.app/Contents/Resources/Calculator.icns
. So you'd have to get the value of CFBundleIconFile
from the App's .plist
file and check whether or not it has the .icns
extension and test to see if it's in the default location, which it normally is but not always.
So in Terminal you'd query using defaults
, e.g.:
defaults read /Applications/Calculator.app/Contents/Info.plist CFBundleIconFile
In AppleScript you could set the results to a variable and go from there, e.g.:
set appIcon to do shell script "defaults read /Applications/Calculator.app/Contents/Info.plist CFBundleIconFile"
It returns: Calculator.icns
Where as,
defaults read /Applications/Utilities/Terminal.app/Contents/Info.plist CFBundleIconFile
Returns: Terminal
Yet the FQP is /Applications/Utilities/Terminal.app/Contents/Resources/Terminal.icns
Best Answer
This code will do it for you:
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.