Re: Checking on the existence of a file
Re: Checking on the existence of a file
- Subject: Re: Checking on the existence of a file
- From: Eric Robertson <email@hidden>
- Date: Fri, 26 Oct 2012 17:40:33 +0100
Subject: Re: Checking on the existence of a file
Date: 24 October 2012 18:30:37 GMT+01:00
On Oct 24, 2012, at 11:55 AM, Eric Robertson wrote: I thought I could use 'exists' to find out if the file I wanted to use was already there but I couldn't find out how to do this. Instead I decided just to use 'try' and 'on error' when I was producing the alias to the file I wanted to use.
Here are some examples of code I use:
1. invisibleTagArchive is a string which begins with "." (an invisible item) and locCont is an alias to a folder (but notice that I used it as text).
tell application "System Events" to exists disk item invisibleTagArchive of disk item (locCont as text)
2. destFolder is an alias to a folder and the name of the file is a string.
tell application "Finder" . . if not (exists file (newFileName & "." & suffixNr & ".emlx") of destFolder) then exit repeat
3. Here, Path is the full path to a folder as text.
tell application "Finder" if not (exists folder Path) then return 0
4. newFileName is a string and destFolder is an alias
tell application "Finder" if (exists folder newFileName of destFolder) then
These have been working correctly for a very long time in 10.6.8 and continue to work in 10.7.
Thanks for these alternative ways of using 'exists' which I've taken a note of - I see all of them use either Finder or System Events.
Eric. |
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden