title: Copy items via Finder and Applescript: how to get "item exists - replace?" dialog in Finder?
body: <p>In my app, I like to have the OSX Finder copy a file or folder.</p>
  
  <p>(<em>Note: I have good reasons for using the Finder instead of using shell cmds, NSWorkspace or other means, so there's no need for suggestions in that direction.</em>)</p>
  
  <p>I am currently relying on Applescript for asking the Finder to perform the copy operation. Here's a sample script for testing:</p>
  
  <pre><code>tell application "Finder"
      try
          copy file POSIX file "/etc/bashrc" to folder POSIX file "/private/tmp"
          -- alternative with same behavior:
          --duplicate POSIX file "/etc/bashrc" to POSIX file "/private/tmp"
      on error errmesg number errn
          display dialog "Error thrown: " &amp; errmesg
      end try
  end tell
  </code></pre>
  
  <p>Now the problem is this: <strong>If the destination item already exists, the script throws an error and cancels the copy operation.</strong></p>
  
  <p>However, <strong>I would rather have the Finder display the "item exists" dialog</strong> that it shows when doing such a copy operation in the Finder interactively, like this one:</p>
  
  <p><img src="https://i.stack.imgur.com/HTCON.png" alt="Finder &quot;item already exists&quot; warning"></p>
  
  <p>Now, here's the thing:
  <strong>If I run this script from the 3rd party app Script Debugger, then this dialog appears!</strong></p>
  
  <p>So, obviously there is a way to get the Finder to display the dialog instead of throwing an exception. But how? Who knows the secret to this?</p>