copying directory structure only

copying directory structure only

Post by john hr » Thu, 03 Jul 2003 19:20:05



Hello Folks,

Is it possible to copy a directory structure without its
content? This is to say copying a directory and all its
subdirectories but not the regular files in them?

I tried with cp and I failed. Is there any other utility
that could help?

Thanks!

john

 
 
 

copying directory structure only

Post by Adam » Thu, 03 Jul 2003 19:59:58



Quote:> Hello Folks,

> Is it possible to copy a directory structure without its
> content? This is to say copying a directory and all its
> subdirectories but not the regular files in them?

> I tried with cp and I failed. Is there any other utility
> that could help?

If I understand correctly what you want, this should do it (tested with
"GNU find version 4.1.7"):

find source/dir/ -type d -exec mkdir target/dir/'{}' ';'

 
 
 

1. copying a directory structure with a particular file in directories below

Hello,
I need some help/advise on how to copy a directory structure with a
particular file in directories below the start directory.

Let's say I have many text files [*.txt] with many data files and other
files [*.data, *.*]
The directory I want to copy across to another area with only the text
files but which also retains the directory structure.

i.e.,

[root_directory]
 |__[data]
       |__[directory_1]
       |__[direcotry_2]
       |    |__[directory_2.1]
       |
       |__[directory_3]
       |
       |__[directory_N]

I want to copy the directory [data] to another area with just the *.txt
files but retain the directory structure.

I tried to do this

cp -r `find /[root_directory]/[data] -name "*.txt"` .

NOTE: The above when I include the square brackets is meant to
represent the full name of the
directory and is not to be confused with anything else.

cp -r `find /root_directory/data/ -name "*.txt"` .

When doing this, all I get is the *.txt files without the directory
structure. If the *.txt files have the same name it will cause
problems. So I can copy the directory structure it would be great.

I hope you can understand the issue/problem statement from my
explanation.
If you have any questions please ask me.

Thanks,
ROuNIN

2. device driver devel HELP

3. HELP:2 ques: Copying large directory structure and mkfs

4. Apache mod_rewrite question

5. How do I copy a whole structure of directory ?

6. source for rm()

7. automatically copy and rename directory structure

8. telnet logs

9. Bash shell script to sort files by date and copy to directory structure

10. Copy entire directory structure from one system to another (Solaris v2.5.1)

11. Copying a directory structure from Unix -> NT via FTP

12. Copying only directory structure

13. using find and copy to copy directories