How to copy files from one directory to another while preserving the directory structure in mac?
I found that you can use cp --parents
in ubuntu but unfortunately that doesn't work in mac.
1. Navigate to the Parent Folder you wish to duplicate (Open Terminal, Type "cd" and then drag the source parent folder onto the Terminal. Enter, you should now see the name of the current directory listed before the $ prompt (the folder/directory that you wish to duplicate without any contents).
Using the command-key, and in the following Finder order, select the file to copy, and then each folder that it is to be copied too. You then right-click on the selected file, and from the Services menu, select the appropriate service.
Copying Directories with cp Command To copy a directory, including all its files and subdirectories, use the -R or -r option. The command above creates the destination directory and recursively copy all files and subdirectories from the source to the destination directory.
I ended up using rsync -R
to solve this.
On OS X you can use ditto <source> <destination>
See here: http://osxdaily.com/2014/06/11/use-ditto-copy-files-directories-mac-command-line/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With