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

Re: if file exists script


  • Subject: Re: if file exists script
  • From: "Mark J. Reed" <email@hidden>
  • Date: Sat, 17 Sep 2005 09:22:56 -0400

The Finder has a Boolean function "exists" that returns true if the
file or folder is there, false otherwise.

But exists requires a Finder file or alias object, and by the time you
do the necessary coercions, there's an easier way that doesn't even
require the Finder's involvement.  It's based on the fact that
coercion to "alias" will only succeed if the file exists.  So:

on fileExists(f)
    try
        f as string as alias
         return true
    on error
        return false
    end try
end


Then you can just use

    if fileExists(...)

or, to avoid any potential name conflicts,

    if my fileExists(...)

anywhere you want to do the test.

On 9/17/05, Bob Cuilla <email@hidden> wrote:
> I need a very simple script to return true or false for the existence
> of a finder file.  I am calling the script from Filemaker before
> creating a same-named file
>
> can you help?
>
> Bob
>
>
>  _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Applescript-users mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>


--
Mark J. Reed <email@hidden>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >if file exists script (From: Bob Cuilla <email@hidden>)

  • Prev by Date: if file exists script
  • Next by Date: Re: Check to see if a computer is running....
  • Previous by thread: if file exists script
  • Next by thread: Cookies and XMLLib.osax
  • Index(es):
    • Date
    • Thread