• 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: Testing for files and/or folders
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Testing for files and/or folders


  • Subject: Re: Testing for files and/or folders
  • From: "Serge Belleudy-d'Espinose" <email@hidden>
  • Date: Thu, 7 Mar 2002 01:35:16 +0100

At 12:55 -0700 6/03/02, Michelle Steiner wrote:

When testing to see if a file or folder exists, do not use this
structure:

if exists (alias "diskname:foldername:filename")

The reason is that the compiler will attempt to resolve the alias at
compile time, and if it can't find it, it will display an alert.

Right, but you can use a variable:

set sPath to "diskname:foldername:filename"
if exists (alias sPath)

The compiler will not bark at this one. And you don't need 'exists' which is a Finder command, just a try block:

try
alias sPath
-- do thing if sPath exists
on error
-- do thing if sPath doesn't exist
end try

Btw, isn't that the alias construct that leaks, shouldn't we use instead

sPath as alias

Emmanuel please?


Serge
--
\\//\//\// Serge Belleudy-d'Espinose Institut Jacques Monod - Jussieu
// // // http://www.ijm.jussieu.fr/ Universites Paris VI, VII - CNRS
//\//\//\\
_______________________________________________
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.

References: 
 >Testing for files and/or folders (From: Michelle Steiner <email@hidden>)

  • Prev by Date: Get a file's icon???
  • Next by Date: Re: managing Scripting Additions
  • Previous by thread: Testing for files and/or folders
  • Next by thread: A good book on learning applescript
  • Index(es):
    • Date
    • Thread