Hey Bob,
On Aug 28, 2011, at 13:07, Robert Poland wrote: This script gets strange (to me) results.
{ name:"Skype.app", creation date:date "Monday, July 18, 2011 08:21:08", modification date:date "Monday, July 18, 2011 08:21:08", size:33607431, folder:true, alias:false, package folder:true, visible:true, extension hidden:true, name extension:"app", displayed name:"Skype.app", short name:missing value, default application:alias "Thor:Applications:Applications (Chris):Internet Apps:Chat Clients:Skype:Skype.app:", kind:"Application", short version:"5.2.0.1572", long version:missing value, bundle identifier:"com.skype.skype", file type:"APPL", file creator:"SKYP", type identifier:"com.apple.application-bundle", busy status:false }
It would seem that Skype does not provide a 'short name'.
Is there a simple way to get the short name of Skype without having to parsing it out.
I think you'll just have to special-case for 'missing value', then get the name, and then trim the file extension. Or you could always get the name and trim it.
set theApp to alias "Thor:Applications:Applications (Chris):Internet Apps:Chat Clients:Skype:Skype.app:"
set shortAppName to short name of (info for theApp) if shortAppName = missing value then set appName to name of (info for theApp) if appName ends with ".app" then set shortAppName to text 1 thru ((offset of ".app" in appName) - 1) of appName
# OR
set {oldTIDS, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "."} set shortAppName to (text items 1 thru -2 of appName) as text set AppleScript's text item delimiters to oldTIDS shortAppName
# OR
set shortAppName to do shell script "sed -E 's/\\.app$//' <<< " & quoted form of appName
# OR my preferred method using the Satimage.osax
set resultAnything to change "\\.app$" into "" in appName ¬ case sensitive false ¬ with regexp
end if end if
Although I love to write terse code your issue is a good example of why I usually force myself to use more steps these days - simply because it makes troubleshooting easier. That's also why I almost never use the result variable anymore.
-- Best Regards, Chris
|