LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 05-24-2007, 10:19 AM   #1
minimole
LQ Newbie
 
Registered: Oct 2006
Location: East Sussex
Distribution: debian
Posts: 12

Rep: Reputation: 0
merge contents of folders


Hi,

I have alot of different folders with alot of files inside of them my question is, is there a way I can take the contents of these folders and merge them into one folder? other wise i have to go through them one by one and it is gonna take a long long time there are about 150 folders and probably about 15000 items inside of them. i have tried a few things but but none seem to work.

Thank you in advance
 
Old 05-24-2007, 10:44 AM   #2
bsdunix
Senior Member
 
Registered: May 2006
Distribution: Caldera, CTOS, Debian, FreeBSD, Mac OS X, Mandrake, Minix, OpenBSD, Slackware, SuSE
Posts: 1,757

Rep: Reputation: 78
You can use the mv command. Just be careful to not overwrite an existing file/folder.

Examples are here:

http://www.linuxcommand.org/lts0050.php

http://members.toast.net/art.ross/Li.../command3.html

Basically to move one directory/folder/file to another (bold italics is example output listing):
Code:
$ ls
dir1 dir2 dir
$ mv dir1 dir
$ ls
dir2 dir
$ cd dir
$ ls
dir1
or
Code:
$ ls
file1 dir
$ mv file1 dir
$ ls
dir
$ cd dir
$ ls
file1
 
Old 05-24-2007, 11:08 AM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
Depending on the complexity of the hierarchy, you may need a script.

For example, suppose DIR_1 has a bunch of files that you want to move to DIR_2:

in DIR_1, "mv * DIR_2" will move everything---but it will also move any directories. (That may be OK in your case)
 
Old 05-24-2007, 05:59 PM   #4
minimole
LQ Newbie
 
Registered: Oct 2006
Location: East Sussex
Distribution: debian
Posts: 12

Original Poster
Rep: Reputation: 0
It is pretty messy. Been trying to write a script but i cant think of a way to do it. the way that have been show is the way i had been doing it and it was taking forever.

It matters not now, I have done it and it took a while lol.
Thank you anyway.
 
Old 05-25-2007, 04:32 AM   #5
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
cd /path/to/base/dir

Code:
find ./ -type f
if that list of files is correct for what you want, then proceed to next command:

Code:
find ./ -type f | xargs mv --target-directory /path/to/some/storage/dir
That should do it, tho, sorry you had to do it by hand..
 
Old 05-25-2007, 05:46 AM   #6
minimole
LQ Newbie
 
Registered: Oct 2006
Location: East Sussex
Distribution: debian
Posts: 12

Original Poster
Rep: Reputation: 0
Thank you i will keep that for future reference. No need to be sorry it wasnt so bad and it encourages me to learn more.

Thank you
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
convert and merge a fat32 to ext3 and then merge w/ another ext3? nkoplm Linux - General 3 03-23-2006 10:37 PM
merge two folders TechNett Programming 1 05-02-2005 08:38 AM
How to compare two folders contents? rvoigt Linux - Newbie 6 01-07-2005 12:35 AM
removing folders & its contents wisdom Linux - General 11 12-24-2004 02:10 AM
ftp: Download folders and contents plisken Linux - General 3 02-20-2002 03:30 AM


All times are GMT -5. The time now is 05:53 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration