• 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: How can I get the name of a deleted original item of an alias?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How can I get the name of a deleted original item of an alias?


  • Subject: Re: How can I get the name of a deleted original item of an alias?
  • From: Shane Stanley <email@hidden>
  • Date: Mon, 31 Aug 2015 23:18:56 +1000

On 31 Aug 2015, at 10:14 pm, S. J. Cunningham <email@hidden> wrote:

How can I get the script to return the name of the original item if the file itself is missing? (Other than resorting to GUI Scripting).

And to answer that part, I think I recall that you're using 10.6, but if I'm wrong, you can use this:

use AppleScript version "2.3.1"
use scripting additions
use framework "Foundation"

on nameOfOriginalFileForAlias:posixPath
tell current application's class "NSURL"
-- make URL
set anNSURL to its fileURLWithPath:posixPath
-- load data from alias file
set theData to its bookmarkDataWithContentsOfURL:anNSURL |error|:(missing value)
-- get value as dictionary from data
set theResult to its resourceValuesForKeys:{current application's NSURLLocalizedNameKey} fromBookmarkData:theData
end tell
-- extract name and coerce to text
return (theResult's objectForKey:(current application's NSURLLocalizedNameKey)) as text
end nameOfOriginalFileForAlias:


-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>

 _______________________________________________
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: How can I get the name of a deleted original item of an alias?
      • From: "S. J. Cunningham" <email@hidden>
References: 
 >How can I get the name of a deleted original item of an alias? (From: "S. J. Cunningham" <email@hidden>)

  • Prev by Date: Re: How can I get the name of a deleted original item of an alias?
  • Next by Date: Re: How can I get the name of a deleted original item of an alias?
  • Previous by thread: Re: How can I get the name of a deleted original item of an alias?
  • Next by thread: Re: How can I get the name of a deleted original item of an alias?
  • Index(es):
    • Date
    • Thread