Re: Get path to a chosen folder
Re: Get path to a chosen folder
- Subject: Re: Get path to a chosen folder
- From: Paul Berkowitz <email@hidden>
- Date: Tue, 26 Nov 2002 11:30:22 -0800
On 11/26/02 11:00 AM, "Mr Tea" <email@hidden> wrote:
>
It seems a little perverse to use the prompt "Choose your File." in a choose
>
folder dialog, but leaving that aside, if you follow the lines of your
>
script with:
>
>
tell application "Finder"
>
exists file mainFile
>
end tell
>
>
...you should get a true or false result.
>
>
AFAIK, 'exists' is not a term that applescript understands, but it is part
>
of Finder's terminology.
True.
>
>
An approach that doesn't use the Finder is to see if you get an error with
>
the line 'alias mainFile' but that's kinda kludgy and a lot less flexible.
How so? There's nothing particular flexible about
tell application "Finder"
exists file mainFile
end tell
is there? it's either true or it's false. Accurate, not flexible.
This works just as well:
try
get alias mainFile
return true
on error
-- other stuff if you want
return false
end try
In fact, in some (many) versions of Finder AppleScript back in OS 8 and 9,
you'd be quite likely to run into problems with the 'exists' method, if you
had just moved or renamed the file, for example, whereas the 'try alias'
method always worked. (They both work well in OS X.) It's not any sort of
kludge, but is precise and accurate. it can even be made to be "flexible" by
adding more code in the 'on error' statement, it can check for error
messages and numbers, etc. You shouldn't malign it, Nick.
>
>
A point to remember when using the Finder to check the existence of a file
>
like this is that it is 'hidden extension agnostic' - ie, it will return
>
true for a file that has a hidden name extension (eg, theFile.txt) whether
>
or not the name extension is given. In this case, the Finder won't
>
distinguish between 'theFile.txt', 'theFile.doc', 'theFile.jpg' etc. if an
>
extension is not specified.
Yes. That can be very useful IF that's what you want. Perhaps that's what
you meant by "flexible"? OK. Granted.
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.