• 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: Checking on the existence of a file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Checking on the existence of a file


  • Subject: Re: Checking on the existence of a file
  • From: "koenig.yvan" <email@hidden>
  • Date: Fri, 30 Nov 2012 16:41:03 +0100


Le 28/10/2012 à 15:13, Luther Fuller <email@hidden> a écrit :

On Oct 28, 2012, at 8:18 AM, koenig.yvan wrote:

No.
Chris Nebel explained that checking the existence of an alias was linked to some features of the operating system which were not guaranteed to be valid in future.
My understanding is that it may be broken if Apple switch from Hfs+ to an other file system as it was rumored several time (and we may be sure that they will switch one day).

Mmmmm. I use this ...

tell application "Finder"
if (exists alias file linkName of mailboxFolder) then

very often in a script. Should I be worried?


Hello

Some of you alreday know that Iam pig headed.
I retrieve the Chris Nebel's message to which I thought :

p://lists.apple.com/archives/applescript-users/2008/Jan/msg00083.html

Re: Check if a file exists fails

Subject: Re: Check if a file exists fails
From: Christopher Nebel 
Date: Sun, 6 Jan 2008 21:02:47 -0800

…
> Also, the most reliable way to determine if a file exists in appleScript is to attempt a coersion to alias:
> try
> set myFile to "hdName:dir:filename" as alias
> set fileExists to true
> on error
> set fileExists to false
>end try

For some definition of "reliable", yes. It works, but I consider this one of the worst bits of AppleScript trickery ever -- its actual meaning is completely obscure, it relies on some undocumented semantics of "alias", it uses an exception to report a boolean condition, and it's a false economy because most of the time you're going to need to talk to some application to use the file anyway. I encourage people to ask the question of Finder or System Events:

tell app "System Events"
exists file "whatever"  --> true or false.
end

Added bonus if you use System Events: it understands POSIX paths; useful if you're into that sort of thing.


--Chris Nebel
AppleScript Engineering


Yvan KOENIG (VALLAURIS, France) vendredi 30 novembre 2012 16:39:06



 _______________________________________________
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: Checking on the existence of a file
      • From: Christopher Stone <email@hidden>
  • Prev by Date: Re: How do I save an array in plist?
  • Next by Date: Re: Checking on the existence of a file
  • Previous by thread: Re: Checking on the existence of a file
  • Next by thread: Re: Checking on the existence of a file
  • Index(es):
    • Date
    • Thread