• 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
Files, Folders and Paths
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Files, Folders and Paths


  • Subject: Files, Folders and Paths
  • From: Gil Dawson via AppleScript-Users <email@hidden>
  • Date: Tue, 9 May 2023 10:37:56 -0700

I've been reviewing Apple's documentation
<https://developer.apple.com/library/archive/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/ReferenceFilesandFolders.html>
 on files, folders, paths and such.  Several examples surprised me.  Here is
one:

Converting a Path to an Alias
The handler in Listing 15-19 converts strings, path objects, POSIX file
objects, Finder paths, and System Events paths to alias format.

Listing 15-19AppleScript: Handler that converts a path to an AppleScript alias

on convertPathToAlias(thePath)
        tell application "System Events"
                try
                        return (path of disk item (thePath as string)) as alias
                on error
                        return (path of disk item (path of thePath) as string)
as alias
                end try
        end tell
end convertPathToAlias

Under what conditions would the first try fail, but the second one succeed?

--Gil
 _______________________________________________
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: Files, Folders and Paths
      • From: Christopher Stone via AppleScript-Users <email@hidden>
    • Re: Files, Folders and Paths
      • From: John Garrigues via AppleScript-Users <email@hidden>
    • Re: Files, Folders and Paths
      • From: Joel Esler via AppleScript-Users <email@hidden>
  • Next by Date: Re: Files, Folders and Paths
  • Next by thread: Re: Files, Folders and Paths
  • Index(es):
    • Date
    • Thread