Re: How to Test for a file ...
Re: How to Test for a file ...
- Subject: Re: How to Test for a file ...
- From: Walter Ian Kaye <email@hidden>
- Date: Wed, 30 Jun 2004 14:09:48 -0700
At 01:24p -0700 06/30/2004, Charles Heizer didst inscribe upon an
electronic papyrus:
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.
There are at least two ways:
set fileLoc to (path to "asup") as string
set fileName to "foo"
tell application "Finder"
if not exists file (fileLoc & fileName) then
make new file at folder fileLoc with properties {name:fileName}
end if
end tell
try
alias (fileLoc & fileName)
on error
open for access file (fileLoc & fileName) with write permission
close access result
end try
Note that using the Finder to create a file will automatically give
the file a "blank" resource fork (286 bytes), whereas the osax file
command will not.
-Walter
"quoth the raven: livermore"
_______________________________________________
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.