• 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: Ed Stockly <email@hidden>
  • Date: Sun, 6 Jan 2008 12:17:53 -0800


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


Bernhard, 

:Index

Is not a valid file reference, which may be why you're getting that particular error.

AppleScript needs the full path:

file "hdName:dir:filename"

works, but

file ":filename"

won't work.

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 fale
end try


HTH, 

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

  • Follow-Ups:
    • Re: Check if a file exists fails
      • From: Christopher Nebel <email@hidden>
  • Prev by Date: Re: Check if a file exists fails
  • Next by Date: Re: Leopard equivalent for getting disk format info
  • Previous by thread: Re: Check if a file exists fails
  • Next by thread: Re: Check if a file exists fails
  • Index(es):
    • Date
    • Thread