Determine which directory to copy/move to

If dropping onto a directory, copy to that dir; otherwise, copy to the
current working directory.

Lots of code duplication.