how do I Merge 2 directories?
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Shell > how do I Merge 2 directories?




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    how do I Merge 2 directories?  
bob the builder


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-21-06 07:49 AM

I have 2 directories with 1000s of files and subdirectories.

there are no doubt some duplicate named files.

I would like to merge the 2 directory structures without clobbering
files with duplicate names.






[ Post a follow-up to this message ]



    Re: how do I Merge 2 directories?  
bob the builder


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-21-06 07:49 AM

i found some answers finally with google

cp -Riv --reply=no test1/* test0/

i can then clean up the source folder with a dup file finder

the rest of the possible answers are below:
===========================
find dir1 -type f | PERL -lne 'm#([^/]*)/(.*)$#;print "mv -i $1/$2
dir2/$2";'|sh

#!/bin/ksh
for i in `find dir1 -type f`
do
new_folder=` echo $i | sed -e 's/dir1/dir2/' `
echo mv $i $new_folder  | sh
done

cd dir1; tar cf - * | (cd ../dir2; tar xvf -)

cp -Rf dir1/* dir2/
rm -f dir1/*






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 08:40 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register