Is it possible to copy a folder to a non empty destination without deleting the contents of the destination folder first? My current implementation is as follows
var folderObject = NSFileManager.defaultManager();
folderObject.removeItemAtPath_error(toPath, nil);
folderObject.copyItemAtPath_toPath_error(fromPath, toPath, nil));
What i need to achieve is overwrite the contents of destination folder with that of source folder.
The call
removeItemAtPath_error
deletes the destination directory andcopyItemAtPath_toPath_error
creates a directory of the same name as the deleted one, hence it is empty.As a side note, the naming of your
NSFileManager
instance is somewhat misleading, as it is not a folder object but a file manager instance reference.An example of how this can be done (I'm unfamiliar with
PyObjC
, so this is only for inspiration):I am assuming that this recursively copies the directories from the source and maintains the directory tree.