Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8632613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:22:36+00:00 2026-06-12T09:22:36+00:00

The script is as below: tell application Finder set destinFolder to (choose folder) try

  • 0

The script is as below:

tell application "Finder"

    set destinFolder to (choose folder)

    try
        move selection to destinFolder
    on error vMessage number -15267
        display dialog "" & vMessage
    end try

end tell

Basically,if a file with the same name has already existed in the destination folder, I want users have the choice to duplicate,replace or just skip that file and continue the next file movement using AppleScript. Just like the pic below.

enter image description here

Update: I know how to display a dialog like the one above,the problem is I don’t know how to implement the “duplicate,replace or just skip” logic in AppleScript. And besides, I want to keep this line:

move selection to destinFolder

Because this line of code show a proper moving progress percentage in a single dialog, using repeat will lose that benefit.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:22:37+00:00Added an answer on June 12, 2026 at 9:22 am

    You can try something like this:

    set destinFolder to (choose folder)
    set destItems to every paragraph of (do shell script "ls " & quoted form of (POSIX path of destinFolder))
    
    tell application "Finder"
        set mySelection to selection
        repeat with anItem in mySelection
            set itemName to anItem's name
            if itemName is in destItems then
                display alert "An item named " & itemName & " already exists in this location. Do you want to replace it with the one you're moving?" buttons {"Skip", "Replace"} default button "Replace"
                if button returned of the result = "Replace" then move anItem to destinFolder with replacing
            else
                try
                    move anItem to destinFolder
                end try
            end if
        end repeat
    end tell
    

    or this:

        set destinFolder to (choose folder)
    
    tell application "Finder"
        set mySelection to selection
        repeat with anItem in mySelection
    
            try
                move anItem to destinFolder
            on error errMsg number errNum
                if errNum = -15267 then
                    display alert "An item named " & itemName & " already exists in this location. Do you want to replace it with the one you're moving?" buttons {"Skip", "Replace"} default button "Replace"
                    if button returned of the result = "Replace" then move anItem to destinFolder with replacing
                else
                    tell me
                        activate
                        display alert errMsg & return & return & "Error number" & errNum buttons "Cancel"
                    end tell
                end if
            end try
    
        end repeat
    end tell
    

    EDIT
    This script will not give you a choice for each item that exists in the destination folder

    set destinFolder to (choose folder)
    
    tell application "Finder"
        set mySelection to selection
        try
            move mySelection to destinFolder
        on error errMsg number errNum
            if errNum = -15267 then
                display alert "One or more items already exist in this location. Do you want to replace them with the ones you're moving?" buttons {"Skip", "Replace"} default button "Replace"
                if button returned of the result = "Replace" then move mySelection to destinFolder with replacing
            else
                tell me
                    activate
                    display alert errMsg & return & return & "Error number" & errNum buttons "Cancel"
                end tell
            end if
        end try
    
    end tell
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The start up script bellow mounts a network drive in my macbook: try tell
The script below should open all the files inside the folder 'pruebaba' recursively but
I have the following script below where I try to mimic a file upload
I can open a Terminal tab using the following AppleScript: tell application Terminal set
I have a powershell script (below) which seems to work but prints an error
Can anyone tell me why when I ran a script with the below contents
The script below works as far as i can tell: <script type=text/javascript language=javascript> $(document).ready(function()
Assuming that the folders exist in the script below, can someone tell my why
The script below works fine if 3 and 3.2 are not links but i
The script below, test.php, is intended to be placed in a specific directory of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.