LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 08-18-2011, 02:02 AM   #1
meet10may
LQ Newbie
 
Registered: Aug 2011
Posts: 9

Rep: Reputation: Disabled
Help in copying multiple files


Hi,
I need some help in copying multiple files from different directory trees to a separate directory tree with same names.
eg. I have a bunch of directories with various sub directories.In each of the sub directory i need to find *.txt files and copy those files into a different directory having same directory tree as my previous directory.
Thanks
 
Old 08-18-2011, 03:02 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959
Uum, ok. You didn't really specify where you need help, but we'll go with it.

So how do we determine which files to copy? What is the directory structure they are in? Where do you want to move them? Are there any "gotchas" to worry about, such as files to avoid?

Most important, what have you tried so far? You have searched the web and LQ, and tried out some things first, right?

Anyway, here's a hint to get you started:

http://mywiki.wooledge.org/UsingFind
 
Old 08-18-2011, 03:18 AM   #3
allwimb
Member
 
Registered: Aug 2011
Posts: 47

Rep: Reputation: Disabled
Here's a little command that will print the name + the path of all the .txt files in the current dir :

for i in `find .`
do
echo $i
done

spring logout

Last edited by allwimb; 12-12-2011 at 05:44 AM.
 
Old 08-18-2011, 03:38 AM   #4
salemeni
Member
 
Registered: Aug 2011
Posts: 64

Rep: Reputation: Disabled
for i in `find /yourdirectory -name *.txt`
do
cp $i destinationPath
done

generics array

Last edited by salemeni; 12-06-2011 at 03:00 AM.
 
  


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
copying multiple files in multiple folders ?? stratotak Linux - Newbie 2 02-21-2009 09:41 AM
Copying Multiple Files babu198649 Linux - Newbie 2 01-23-2009 07:43 AM
Kaudiocreator seems to hang copying multiple files tur third Linux - Software 6 03-28-2006 03:49 PM
Copying files from multiple folders into one aardwolf64 Linux - General 4 01-02-2006 11:53 PM
copying multiple files..??? krazykow Linux - Enterprise 6 09-09-2004 01:05 AM


All times are GMT -5. The time now is 11:26 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration