title: Check if file/folder exists, if so delete it, if not display message... trouble in AppleScript
body: <pre><code>set theFile to ((&quot;Macintosh SSD:private:var:root:Desktop:new&quot;) as text)
   set status to false as boolean
  
  tell application &quot;Finder&quot; to if exists theFile then set status to true
   if status is true then
    delete theFile
  else
   display alert &quot;No file.&quot;
  end if
  </code></pre>
  <p>With this code I get the alert &quot;No file&quot; as expected when the file/folder named &quot;new&quot; is not on the desktop, however when the file is there it will not delete it and instead gives me a script error. Any suggestions on how to fix this? many thnx!
  <br>
  <br>
  <a href="https://i.stack.imgur.com/oF2Wx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oF2Wx.png" alt="enter image description here" /></a></p>
  <br>