Re: How to Test for a file ...
Re: How to Test for a file ...
- Subject: Re: How to Test for a file ...
- From: Joe Klemmer <email@hidden>
- Date: Fri, 02 Jul 2004 13:04:25 -0400
- Organization: Unix System/Network Administrator & Ad Hoc Programmer
On Thu, 2004-07-01 at 13:40, Laine Lee wrote:
>
> 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.
This might be a little cleaner (assuming you have set your shell to
bash)...
do shell script "[ -f <yourfilename> ]" # this will return true #
if the file exists and
# is a regular file
do shell script "[ -s <yourfilename> ]" # this will return true
# if the file exists and
# is a regular file that
# is not an empty file.
You can also do negative logic by adding a "!" in front of the switch,
like -
do shell script "[ ! -f <yourfilename> ]" # this will return true
# if the file DOESN'T
# exist
--
Joe Klemmer <email@hidden>
Unix System/Network Administrator & Ad Hoc Programmer
_______________________________________________
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.