• 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: How to Test for a file ...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to Test for a file ...


  • Subject: Re: How to Test for a file ...
  • From: Laine Lee <email@hidden>
  • Date: Thu, 01 Jul 2004 12:40:19 -0500

> Hello,
> I was wondering if anyone could tell me how to test if a file exists?
> So, if it does not I can create the file.

Here's one way, assuming you use OS X and TextEdit is in your Applications
folder.

------------
set posix_item_in_question to "/Applications/Regretit.app"
repeat
set hfs_textedit to (POSIX file posix_item_in_question)
try
get hfs_textedit as alias
exit repeat
on error
display dialog "Did you mean \"TextEdit\"
instead of
\"Regretit\"?
" buttons {"Cancel", "Of Course I did!"} default button 2
if button returned of result is "Of Course I did!" then
set posix_item_in_question to "/Applications/TextEdit.app"
end if
end try
end repeat
do shell script "/usr/bin/open " & posix_item_in_question
------------

--
Laine Lee
email@hidden
http://lonestar.utsa.edu/llee
_______________________________________________
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.


  • Follow-Ups:
    • Re: How to Test for a file ...
      • From: Joe Klemmer <email@hidden>
  • Prev by Date: Re: Sorry
  • Next by Date: Re: (FWIW) A Few Additional Notes On Missing Link...
  • Previous by thread: Re: (FWIW) A Few Additional Notes On Missing Link...
  • Next by thread: Re: How to Test for a file ...
  • Index(es):
    • Date
    • Thread