automatically copy and rename directory structure

automatically copy and rename directory structure

Post by Yang xi » Wed, 09 Oct 2002 03:28:15



Hi all,
I received a request from a user to copy and rename the following
directory structure
./clients2002/
./clients2002/client12002
./clients2002/client12002/client1Q1
./clients2002/client12002/client1Q1/portf1Q1/
./clients2002/client12002/client1Q1/portf2Q1/
./clients2002/client22002
...
you get the picture.
I want to copy the directory structure and it's dirs of the previous
quarter and make a new one for the current quarter without copying the
files in the dir itself.

I guess I can start with
find /dir type -d -depth -2 .....
please help.

Thanks in advance.

Yang

 
 
 

automatically copy and rename directory structure

Post by ScriptOmati » Wed, 09 Oct 2002 04:09:44



> Hi all,
> I received a request from a user to copy and rename the following
> directory structure
> ./clients2002/
> ./clients2002/client12002
> ./clients2002/client12002/client1Q1
> ./clients2002/client12002/client1Q1/portf1Q1/
> ./clients2002/client12002/client1Q1/portf2Q1/
> ./clients2002/client22002
> ...
> you get the picture.
> I want to copy the directory structure and it's dirs of the previous
> quarter and make a new one for the current quarter without copying the
> files in the dir itself.

> I guess I can start with
> find /dir type -d -depth -2 .....
> please help.

> Thanks in advance.

> Yang

Yes, but I do not see the reason for -depth option unless you really
want to limit it

X=-x; # for debug
X=;   # otherwise
# optionally remove the NEW directory before recreating it
# rm -rf /someotherdir

| sh ${X} ))

--
http://ftp.opensysmon.com is a shell script archive site with an
opensource system monitoring software package designed for scripts
and fully compatible with cron.

 
 
 

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. Is it possible to run Netmeeting through IP Masquerade?

3. Batch rename of files including directory structure

4. ATI XPERT@PLAT AGP

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

6. help with queues

7. copying directory structure only

8. ipnat with ppp0/tun0

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

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

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

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

13. Copying only directory structure