• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Missing value
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Missing value


  • Subject: Re: Missing value
  • From: Robert Poland <email@hidden>
  • Date: Sun, 28 Aug 2011 14:42:05 -0600

Thanks Chris & Ron,

This is what I choose to do;

set applicationName to (info for (path to frontmost application))'s short name
if applicationName = missing value then -- for apps with no short name
set applicationName to (info for (path to frontmost application))'s name
set applicationName to change "\\.app$" into "" in applicationName ¬
case sensitive false ¬
with regexp
end if


On Aug 28, 2011, at 1:10 PM, Christopher Stone wrote:

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

Robert Poland - Fort Collins, CO



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Missing value
      • From: KOENIG Yvan <email@hidden>
References: 
 >Missing value (From: Robert Poland <email@hidden>)
 >Re: Missing value (From: Christopher Stone <email@hidden>)

  • Prev by Date: Re: Missing value
  • Next by Date: Re: Missing value
  • Previous by thread: Re: Missing value
  • Next by thread: Re: Missing value
  • Index(es):
    • Date
    • Thread