Re: Evaluating if a file exists
Re: Evaluating if a file exists
- Subject: Re: Evaluating if a file exists
- From: Laine Lee <email@hidden>
- Date: Wed, 09 May 2007 17:47:35 -0500
- Thread-topic: Evaluating if a file exists
On 5/7/07 2:24 PM, "Emmanuel" <email@hidden> wrote:
> At 10:34 AM -0700 5/7/07, Christopher Nebel wrote:
>> On May 7, 2007, at 10:22 AM, Emmanuel wrote:
>>
>>> At 1:08 PM -0400 5/7/07, email@hidden wrote:
>>>
>>>> set theDestFolder to alias
>>>> "DONNELLY:Users:andrewd:Desktop:TheDestFolder:"
>>>> [...}
>>>> if not (exists file (theDestFolder & x as string)) then
>>>
>>> That was not your question, and I may very well be missing
>>> something, but I'm surprised that this could work: I can't see what
>>> Finder (or AppleScript) will do when asked to concatenate an alias
>>> with a string. For me, that very line should make an error.
>>
>> Don't forget, "&" means list concatenation as well. The result of
>> "alias & text" is {alias, text}. Will Finder be able to do anything
>> sensible with that, no, but it's semantically valid.
>
> Yes, thanks.
>
> Emmanuel
Here is a script that might be useful for testing all cases suggested by the
following example.
try
do shell script "rm ~/Desktop/.DS_Store"
end try
And here's the example, which appears to suggest a possible method for
determining a file's presence.
set theDestFolder to (path to desktop as Unicode text)
try
if exists ((theDestFolder & ".DS_Store") as alias) then
end if
display dialog "Your desktop appears normal."
on error
display dialog "Don't you ever use your desktop?"
end try
The following example, however, appears to achieve the same result, but only
if the specified file is present. If the file isn't present, OMM (10.4.9)
when running in the Script Editor, the Script Editor promptly crashes.
set theDestFolder to (path to desktop as Unicode text)
try
if exists ((theDestFolder & ".DS_Store") as file specification) then
end if
display dialog "Your desktop appears normal."
on error
display dialog "Don't you ever use your desktop?"
end try
Can you explain why?
--
Laine Lee
_______________________________________________
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