Unable to ask applescript 'if file exists' 'else'
Hello everybody!
I've been googling for hours on end for this. Can't find anything.
I thought it would have been simple enough: get applescript to do a check to see if a file exists, and do something. If it does not exist, do something else.
My script is (more or less) as follows:
set file_yes to (("~/") & "FILE.txt")
tell application "Finder"
if exists file file_yes then
do shell script " SHELL SCRIPT " with administrator privileges
tell application "Finder" to display alert "Shell Script complete!"
try
do shell script "rm ~/FILE.txt" with administrator privileges
end try
else
tell application "Finder" to display alert "No file!"
end if
end tell
But the program constantly skips to 'No file!'. All I get is that alert. I cannot get the 'shell script complete' message, nor delete the file. What am I doing wrong?
FYI: I am not an applescript expert (as you can tell...). I know a bit of it and make many programs for myself, but I can't get this one going. I know the basics. Not everything.
Thanks in advance!
MacBook Pro, Mac OS X (10.7.5)