Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I create an Automator workflow, service or folder action to use ditto. The intention here is to use ditto to merge folders and/or files avoiding the unacceptable Finder's behavior of replacing the folder/file by the new one.

share|improve this question
up vote 0 down vote accepted

Create a Service that receives folders in Finder. Add a single Run AppleScript action to it with the following script code:

on run {input, parameters}
    set dest to choose folder with prompt "Select destination:"
    set dest_path to (POSIX path of dest) as text
    set src_paths to ""
    repeat with idx from 1 to count (input)
        set src_paths to src_paths & (quoted form of (POSIX path of item idx of input as text)) & " "
    end repeat
    set cmd to "ditto " & src_paths & quoted form of dest_path
    do shell script cmd
end run

The script will execute

ditto selectedFolder1 selectedFolder2 selectedFolderN folderChosenInDialog

Assign a keyboard shortcut for convenient access in System Preferences » Keyboard » Keyboard Shortcuts » Services.

share|improve this answer
Thank you. I'll try it and let you know. – tenshimsm Mar 24 '11 at 12:12
It works but not in the way I want. But it's my fault. I want to copy a folder named "my files" from a flash drive to a folder also named "my files" in my Documents folder (for example) what it should do is update the files not delete all the content and replace with the new one as is the default behavior. Like in Linux or even Windows. – tenshimsm Mar 24 '11 at 16:42
@tenshimsm Cannot reproduce. It doesn't clear destination for me. I gave you the command that is executed in my post, and you specifically requested use of ditto. If you want to add parameters to change ditto's behavior, it's trivial to edit the third to last line. – Daniel Beck Mar 24 '11 at 17:51
@tenshimsm Screenshot when I tested it. Clearly 1 is destination, and c existed only there, before performing the command. – Daniel Beck Mar 24 '11 at 20:03
Your code is very useful for me. I try it and see if it is my "lameness". :) – tenshimsm Mar 25 '11 at 20:05

You must log in to answer this question.

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