How do I copy folder/directory structure without copying the contents?

Saw a previous article but it was the terminal code instructions didn't work for me. Would love a little help. I'm not real tech inclined so dumb it down as much as you are able!

iMac (2017 – 2020)

Posted on Sep 9, 2023 4:16 PM

Reply
5 replies

Sep 14, 2023 4:18 AM in response to Garkle

Modern versions of macOS use the APFS file system. You can duplicate the entire folder structure and it won't take any additional space.


Then, open a new Finder window for the new folder. Or maybe create a new folder and move your copied folder into it. Open that folder. The trick is that you want only a single folder in a Finder window.


Change the Finder window view style to list.

Hold down the option key and click on the disclosure triangle next to your new folder.

This will expand the folder and all of the subfolders it contains.

Select all.

Go through the list. For each subfolder, hold down the command key and click it to deselect.

Once you have all of the subfolders deselected, drag them to the trash.

You're done.

Sep 14, 2023 6:49 AM in response to Garkle

Even simpler than etresoft's solution:


Duplicate the folder (File > Duplicate)


Using Terminal,

find <drag the duplicated folder here> -type f -delete


This will create a duplicate of the original folder, retaining all its subfolders, while removing all files within those folders.


The above is what I interpreted your question to mean. If that's not what you want to do though please explain.


Beware when using Terminal, there is no confirmation and there is no "undo" so don't do anything without a backup.

How do I copy folder/directory structure without copying the contents?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.