Re: Check if a file exists fails
Re: Check if a file exists fails
- Subject: Re: Check if a file exists fails
- From: Matthew Smith <email@hidden>
- Date: Sun, 06 Jan 2008 09:39:32 +1100
- Thread-topic: Check if a file exists fails
on 06/01/2008 09:23, Bernhard Waldbrunner at email@hidden wrote:
> I'm working on a small Folder Action Script, whose second line looks
> like (exactly how I learned from the AppleScript Language Guide):
> if (the file ":Index" exists) then
>
> Running this script always results in an error which reads "Can't get
> file :Index."
> Now, this file really doesn't exist because I can't run it as a Folder
> Action in order to test/debug the script. However, this shouldn't be
> an issue since this file doesn't have to exist.
>
> So, I tried this:
> if (POSIX file "Index" exists) then
>
> And I get the error message "Can't make file ':Index' into type
> reference." Not really helpful ...
>
> I also tested placing "exists" in front of everything as in "if
> (exists ...", same errors.
>
> What am I missing, is this approach deprecated? I am running Mac OS X
> 10.5.1, AppleScript 2.0.
Try wrapping it in a tell application "Finder" block.
tell application "Finder"
if file ":Index" exists then
....
--
Matthew Smith
_______________________________________________
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