• 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: trivial Finder path problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: trivial Finder path problem


  • Subject: Re: trivial Finder path problem
  • From: Christopher Stone <email@hidden>
  • Date: Sat, 10 Dec 2016 15:37:20 -0600

On Dec 10, 2016, at 07:47, Yvan KOENIG <email@hidden> wrote:
but
tell application "Finder" to get (POSIX file ("/System/Library/Fonts/" & "Menlo.ttc")) as alias  behaves flawlessly.


Hey Yvan,

Thanks.  I'd forgotten that little gimmick.

Running in the Script Editor with the Log History window open I get:

-------------------------------------------------------------------------------------------
tell application "Finder"
    get POSIX file "/System/Library/Fonts/Menlo.ttc"
       --> error number -1728 from POSIX file "/System/Library/Fonts/Menlo.ttc"
end tell

Result:

alias "Mercury:System:Library:Fonts:Menlo.ttc"
-------------------------------------------------------------------------------------------

-1728 → The referenced object doesn’t exist. This is a run-time resolution error, such as when attempting to reference a third object when only two objects exist.

-------------------------------------------------------------------------------------------

The code works and yet produces an error.

I continue to prefer to keep the Finder and POSIX Paths widely separate.

The Finder likes aliases, HFS paths, and FURLs («class furl»).  When I stick to those I rarely have any problems.

Since System Events is better behaved these days and understands $HOME-based POSIX Paths, I don't mind using it in an alias-from-path-string handler:

-------------------------------------------------------------------------------------------
set thePath to "~/Downloads" -- $HOME-based POSIX Path.
set myAlias1 to makeAliasFromPathString(thePath)

set thePath to "/Users/chris/Downloads" -- POSIX Path
set myAlias2 to makeAliasFromPathString(thePath)

set thePath to (path to downloads folder as text) -- HFS Path
set myAlias3 to makeAliasFromPathString(thePath)

on makeAliasFromPathString(thePath) -- Input: POSIX-Path, Tilde-Path, or HFS-Path
    tell application "System Events" to set thePath to POSIX path of disk item thePath
    return (POSIX file thePath) as alias
end makeAliasFromPathString
-------------------------------------------------------------------------------------------

--
Take Care,
Chris

 _______________________________________________
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: trivial Finder path problem
      • From: Yvan KOENIG <email@hidden>
References: 
 >Re : trivial Finder path problem (From: Yvan KOENIG <email@hidden>)

  • Prev by Date: Re : trivial Finder path problem
  • Next by Date: Apple script command help please
  • Previous by thread: Re : trivial Finder path problem
  • Next by thread: Re: trivial Finder path problem
  • Index(es):
    • Date
    • Thread