1

Using and Automator Service and an AppleScript that is redly available and exists on this thread of but a "GUI" around ditto. The solution works well, however, I am not getting the behavior I expected. Ditto, without modification, copies a folder to a dest folder and creates the folder if it doesn't exist. The behavior I get with the service is the contents are copied into the destination. Can someone give me a hand in getting the applescript modified to that the folder is copied to the destination not the contents into the destination? Script follows:

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
1

2 Answers 2

0

Try using cp -Rf instead. Ditto doesn't seem to support what you're trying to do. Also, make sure the source path doesn't end with a "/". cp will copy the directory's contents like ditto if the path ends in a "/".

0

I have no idea how to make this work with AppleScript but assuming you wish to copy the directory foo to bar with ditto creating bar then

    ditto foo bar/foo

You can create intermediate directories also. As an example you wish to copy the directory biz in the hierarchy bar/foo/baz. The directories bar and foo have already been created then

    ditto biz bar/foo/baz/biz

You must log in to answer this question.

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