• 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: Check if a file exists fails
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Check if a file exists fails


  • Subject: Re: Check if a file exists fails
  • From: "Stockly, Ed" <email@hidden>
  • Date: Mon, 07 Jan 2008 12:18:04 -0800
  • Thread-topic: Check if a file exists fails

 >Me> file ":filename"
>>
>> won't work.
>
> No, it's valid, but it's not particularly well-defined.  HFS paths with a
leading colon are relative to the current working directory.

Yes, I seem to remember finding out that

":" as alias

Worked, but I never really relied on that. Instead of saying it  "won't
work" I should have said "may not be reliable".

>Me> Also, the most reliable way to determine if a file exists in appleScript is
to attempt a coersion to alias:


> 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.


Well, yea that's all true, but it works. That's what I mean by reliable,
also, it works in every version of AppleScript since Mac OS 7.1.

Many appleScripters and our users are still using older versions of the OS
and we need that backward compatibility.

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

Cool.  I'm using System Events more and more to handle various tasks.

>>>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 don't get this one. I haven't tested lately, but I know in the past the
coercion to alias was much faster whether the item existed or not than using
the finder exists command even, if done within a finder tell.

Don't know about System Events.

ES

 _______________________________________________
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

  • Prev by Date: Re: Script doesn't work in Leopard anymore...
  • Next by Date: Re: Script doesn't work in Leopard anymore...
  • Previous by thread: Re: Check if a file exists fails
  • Next by thread: Leopard equivalent for getting disk format info
  • Index(es):
    • Date
    • Thread