LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-21-2006, 01:52 AM   #1
syssyphus
LQ Newbie
 
Registered: Aug 2005
Posts: 19

Rep: Reputation: 0
how do I Merge 2 directories


How would one elegantly merge 2 directory structures without clobbering files with duplicate names?

Last edited by syssyphus; 05-30-2007 at 12:45 AM.
 
Old 01-21-2006, 02:07 AM   #2
GrueMaster
Member
 
Registered: Aug 2005
Location: Oregon
Distribution: Kubuntu.
Posts: 848

Rep: Reputation: 30
Try "mv --reply=no <source> <destination>" (where <source> is one directory and <destination> is the other). The --reply=no option will tell mv not to override files. You'll end up with all but the duplicate files moved, which you can manage individually from there.
 
Old 01-21-2006, 02:15 AM   #3
syssyphus
LQ Newbie
 
Registered: Aug 2005
Posts: 19

Original Poster
Rep: Reputation: 0
this shell script does the trick:

http://shellscripts.org/project/mvpartial

Last edited by syssyphus; 05-30-2007 at 12:48 AM.
 
Old 01-21-2006, 02:34 AM   #4
syssyphus
LQ Newbie
 
Registered: Aug 2005
Posts: 19

Original Poster
Rep: Reputation: 0
The mv command runs into issues with colliding filenames, but the shell script above seems to work fine.

Last edited by syssyphus; 05-30-2007 at 12:51 AM.
 
Old 01-21-2006, 02:47 AM   #5
GrueMaster
Member
 
Registered: Aug 2005
Location: Oregon
Distribution: Kubuntu.
Posts: 848

Rep: Reputation: 30
Hmm. Ok, try using tar. Example:

cd <source-dir>
tar -cf - .|(cd <dest>;tar -kxvf -)

I just tested this, and it worked on a limited scale. I also use this when I upgrade harddrives. Transfered 80G of mp3 & ogg files fairly quickly from an 80g to a 120g drive.

Your tar example will overwrite files BTW.

Last edited by GrueMaster; 01-21-2006 at 02:48 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to merge two mailboxes--------------------- dhanju Linux - Newbie 5 05-10-2010 06:35 AM
merge directories d-fens Linux - General 9 02-04-2010 05:48 PM
Searching multiple directories and sub directories for a file jeep99899 Linux - Newbie 2 10-13-2005 12:23 PM
merge partitions? Leonig Mig Linux - General 2 06-06-2005 11:15 AM
merge mailboxes illtbagu Linux - Software 0 03-13-2004 01:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration