I can copy files using the terminal like this

cp -r path/to/folder1 path/to/folder2

However, this has some limitations:

  • Conflicts are not resolved nicely: do I want to overwrite, rename, abort?
  • Progress bar is not shown

Would it be possible to instead call a third party app to deal with these edge cases for me? What I am thinking in particular is programmatically telling Finder "copy these files from src to dst"

I would expect it to be something like this API

finder --headless --copy --src path/to/folder1 --dst path/to/folder2

Is there a way to achieve this?

  • Your best bet is to use AppleScript via osascript. – lhf Apr 9 '19 at 14:12
  • Are there any resources that you recommend? – Andrei Cioara Apr 9 '19 at 14:31
  • 3
    See stackoverflow.com/questions/29757791/applescript-to-copy-files for instance. – lhf Apr 9 '19 at 15:14
  • 1
    You might want to take a look at this answer.. (Also see this update) Altho' it's for the "Trash" function, and it uses Python, the salient bit of it is that it uses osascript to invoke Finder. IMHO, that's the best approach: re-use something that already works with the system. – Seamus Apr 9 '19 at 18:55
  • This is how I do it on my system, although my shell functions are written in FiSh. But it’s really good to have rm execute a Finder trash command, after I once accidentally deleted by system files and now never have to worry about that again. It’s nice having an undo option for the Finder moves and copies, too. Did you use any of the links above, or should I try and translate my FiShy functions into bashy ones, if bash is what you use? – CJK Apr 17 '19 at 15:47

You must log in to answer this question.

Browse other questions tagged .