Copy only folders not files?

Posted by Shannon on Ask Ubuntu See other posts from Ask Ubuntu or by Shannon
Published on 2013-10-25T21:33:40Z Indexed on 2013/10/25 22:11 UTC
Read the original article Hit count: 292

Filed under:
|

Is there a way to copy an entire directory, but only the folders? I have a corrupt file somewhere in my directory which is causing my hard disks to fail.

So instead of copying the corrupt file to another hard disk, I wanted to just copy the folders, because I have scripts that search for hundreds of folders, and I don't want to have to manually create them all.

I did search the cp manual, but couldn't see anything (I may have missed it)

Say I have this structure on my failed HDD:

dir1
    files
    dir2
        files
        files
        dir4
dir3
files

All I a want is the directory structure, not any files at all.

So I'd end up with on the new HDD:

dir1
    dir2
        dir4
dir3

Hoping someone knows some tricks!

© Ask Ubuntu or respective owner

Related posts about directory

Related posts about cp