How to Copy the folder structure without the Folder contents?

I would like to create an archive of important application installers and I will sync the contents between two systems MacPro and Macbook Pro.


I need to pull the names of the application/developers from somewhere so I figured I would use the Application Support directory.


So I need a way to copy this directories folder structure without any of the file contents. Is there an easy way to do this. I found a post with an Automator script but the link is dead (http://homepage.mac.com/red_menace/.Public/~OSX/Automator/Actions/Copy%20Folder% 20Structure.action.zip) and the thread is archived:


https://discussions.apple.com/thread/1938524?answerId=9147704022#9147704022&searchText=copy%20folder%20structu re#9147704


I also found this post that refers to doing it in terminal but since it is the app support directory I am wary to do this as I am not familiar with terminal at all and I am not clear on what exactly to write in the old_dir / new_dir section. I figure it would be something like this /Library/Application Support but I dont want to make a mistake.


Here is the Terminal command:

cd old_dir

find . -type d -depth -print | cpio -pd new_dir


from:

https://discussions.apple.com/thread/1938524?answerId=9147704022#9147704022&searchText=copy%20folder%20structu re#9147704?searchText=copy%20folder%20structure


Does anyone know of a novice way to do this?

Posted on Apr 28, 2012 9:51 PM

Reply
9 replies

Jul 10, 2017 4:44 PM in response to drwebmail

I think I just came across the novice's way - I'm doing this same thing for tax time, I need to keep a specific set of folders, but want to clear out all the tax receipts but keep the structure.

1. created a new 2017-18 folder, and made a copy (option+drag) of my existing tax subfolders into it

2. go into the 2017-18 folder, and do a search for "." (without the quotes)

3. make sure the find filter is set to 2017-18 folder instead of everything on your mac (that would end quite badly)

4. delete all the results (I might recommend a TM backup just incase you get the context of the folder filter incorrect)

Apr 28, 2012 11:01 PM in response to drwebmail

Actually that find command does do what I think you want. Generalized it might look like:


find old_dir -type d -depth -print | cpio -pd new_dir


Where old_dir and new_dir could be full pathnames if you like so you wouldn't have to cd into old_dir.


Try it for yourself. Use a test fiolder to experiment. The command is not going to do any damage.

May 3, 2012 4:42 PM in response to X423424X

Thanks as well X423424X. But I'm also having difficulty getting the Terminal command to work.

Here is what I enter and the result of my query:


DRs-Macbook-Pro:~ DR$ find /Library/Application Support -type d -depth -print | cpio -pd /Users/DR/Desktop/Test

find: /Library/Application: No such file or directory

find: Support: No such file or directory

0 blocks

May 3, 2012 5:29 PM in response to drwebmail

Special characters in pathnames in terminal commands need to be "escaped" so that they become significant characters in the pathname (or the pathname quoted by enclosing in quote). Such characters are escaped by preceeding them with a backslash. Blanks are one of those special characters. Thus a filename like Application Support should be written as Application\ Support (or as quoted like "Application Support"). So, for example, your command should be written:


find /Library/Application\ Support -type d -depth -print | cpio -pd /Users/DR/Desktop/Test


Note the backslash in Application Support.

May 3, 2012 5:41 PM in response to drwebmail

Your posted workflow isn't doing anything with the input items. Drag the action into the Automator workflow area - when the workflow is run, it will copy the folder structure from the folder specified in the action into the items passed to it (for example, items passed to the workflow when used as a Service, or from an action such as Ask for Finder Items).

Aug 6, 2012 5:59 PM in response to red_menace

Thanks for your help. Im still not clear though. Sorry I have never used automator before so this is very new to me.


Here is a screenshot of my latest attempt:


http://screencast.com/t/vpLJ1UXO7dN


I've made a few (presumably incorrect) assumptions:

1. This is a folder action (which I click it I am asked to choose)

2. I put the destination folder in the top (folder action receives files and folders added to)

3. I drag the copy folder structure action to the automator window (and put the source folder here)

4. I add "get specified finder items" at the beginning of the workflow (and leave it blank).

Aug 7, 2012 6:39 PM in response to drwebmail

Your workflow should copy the folder structure (or at least the first level) form the Application Support folder into folders added to the attached folder (and any from the Get Specified Finder Items action). If the Copy Folder Structure action is getting an error, it should be listed in a dialog (it looks like the action was stopped for whatever reason).

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to Copy the folder structure without the Folder contents?

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