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:41:24 +0100
Le 24 oct. 2012 à 17:55, Eric Robertson a écrit :
[...] I am now using TextWrangler to save away the details!
Hello Eric,
Are those details just made of plain text? In which case it could well be that you don't need to make use of an application at all...
Yes, they're all plain text.
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.
Perhaps could you download this one:
https://developer.apple.com/library/mac/documentation/AppleScript/Conceptual/AppleScriptLangGuide/AppleScriptLanguageGuide.pdf
While possibly not the most up to date wrt the latest changes in the OS, that document still remains invaluable; for example:
"Third-party scriptable applications also provide commands you can use in scripts. Many support all or a subset of the Standard commands, described in Technical Note TN2106, Scripting Interface Guidelines. These include commands such as delete, duplicate, exists, and move, as well as application implementations of AppleScript commands, such as get and set."
Many thanks for mentioning this - I've downloaded it and will keep it beside me. The "exists" command is thus supposed to be supplied by an application (ie its handling isn't provided by AppleScript itself). Yvan already has suggested to make use of the exists command from System Events. In addition, Luther mentioned the Finder as providing an exists command (with some restrictions).
Yes, I hadn't appreciated that 'exists' is not a straight AppleScript command and has to be used in Finder or System Events. As you said earlier it's a great pity that AppleScript doesn't report if a call is made out of context. That said, the approach relying on a try block around a coercion of an HFS path into an alias has often been used as well.
I'm glad that what I'd done with the try block was reasonable. I had tried it out and I knew it worked but wondered if perhaps it was not a good way of getting round trying to set an alias to a non-existence file. HTH, Axel
Very helpful comments.
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