Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

copy files while preserving directory structure in mac

Tags:

macos

cp

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.

like image 504
Sudar Avatar asked Mar 25 '14 18:03

Sudar


People also ask

How do I copy an entire folder structure without copying the files 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).

How do I copy a file to multiple folders on a Mac?

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.

How do I copy a folder with all its contents?

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.


2 Answers

I ended up using rsync -R to solve this.

like image 134
Sudar Avatar answered Sep 30 '22 10:09

Sudar


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/

like image 22
cauboy Avatar answered Sep 30 '22 12:09

cauboy