2

The file, "Test.file" in the below code does not exist, yet the script returns true. Why? What am I doing wrong?

set thePath to (path to application support folder from user domain)

if exists thePath & "Test.file" then
display dialog "The file was found!" buttons {"OK"} default button 1
else
display dialog "The was file wasn't found." buttons {"OK"} default button 1
end if

1 Answer 1

2

You need to reference a file for the test to function properly.

set thePath to path to application support folder from user domain
tell application "System Events" to exists file ((thePath as text) & "Test.file")

With the conditional:

set thePath to path to application support folder from user domain
tell application "System Events" to exists file ((thePath as text) & "Test.file")
if the result then
    display dialog "The file was found!" buttons {"OK"} default button 1
else
    display dialog "The was file wasn't found." buttons {"OK"} default button 1
end if
2
  • The code does not compile with conditional. Commented Dec 3, 2013 at 15:19
  • I have added the syntax for the conditional.
    – adayzdone
    Commented Dec 3, 2013 at 17:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .