How to copy folder structure without files into a new directory on MacOS Catalina?

I've looked this up and tried everything using rsync and involving find ., but keep getting errors. Using rsync I get "rsync error: errors selecting input/output files, dirs (code 3)", and using find . all my subfolders I want to copy say "read-only file system." I've seen that this is a common issue with Catalina, however. Is there an alternate solution that will allow me to copy just the folder structure (without the files) into a new directory? Thanks!

1

2 Answers

Say you cded to the folder you want to copy, and the destination is ~/kiki.

You can just run

find . -type d -exec mkdir -p ~/kiki/{} \;

and you're done.

7

Try without rsync:

The following will list all directory structure without files:

# find . -type d

to add a prefix for each input line (not really useful as standalone command)

# sed 's/^/mkdir /'

put it together:

# find . -type d | sed 's/^/mkdir /'

creating the script, so you can create the Directory structure later:

# find . -type d | sed 's/^/mkdir /' > DirStructure.sh
# chmod +x DirStructure.sh

then, run the script "./DirStructure.sh" in order to create the directory tree wherever you want, whenever you want.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like