Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to copy folders

Status
Not open for further replies.

lpb71

Technical User
Mar 10, 2004
57
GB
I have a folder named branch1 containing 3 subfilders, Does anyone have a script that I could use to copy this folder and its subfolders 160 times naming each copied folder branch2, branch2..etc.

Thanks.
 
If seq is available on your system:

[tt]seq 2 160 | xargs -t -i cp -r branch2 branch{}[/tt]

Annihilannic.
 
That seems to be doing it.

Many Thanks
 
If I wanted to do this with arguments ie 160 branch1 and branch{} all being arghuments. how would I do this. I habe tried using $1 $2 & $3 but says folder does not exist.
 
Can you post your entire script?

Did you make the source directory before testing it?

Annihilannic.
 
seq 2 $1 | xargs -t -i cp -r $2 $3{}

Thanks
 
Looks fine to me, tested it here too and it works. Like I said, are you sure you created the source directory first?

Annihilannic.
 
Sorry, I had a typo '-' in front of cp.

Many Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top