LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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-02-2006, 11:23 AM   #1
aardwolf64
LQ Newbie
 
Registered: Jan 2006
Posts: 6

Rep: Reputation: 0
Copying files from multiple folders into one


I've been using Linux as the primary OS on my web server for quite some time, and now use a Mac as my everyday computer at home. Generally I have been able to Google for anything I have needed, but the solution to this eludes me. Here's what I want to do:

Problem: I have many image files spread out in multiple folders from years of doing things, and I'd like to somehow get all of these into one folder without manually copying each one. I have been able to get a list of all of them using the find command. Is there a way to use the output from that and somehow feed it into the cp command, while still being able to choose an output folder?

I've tried using the pipe, but obviously cp needs more than one argument so it's not working for me.
 
Old 01-02-2006, 11:32 AM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Squeeze
Posts: 5,805

Rep: Reputation: 324Reputation: 324Reputation: 324Reputation: 324
If the filelist has one item per line, and if each line has the full path to the file name, you could try:

cp < filename.txt /path/to/new/folder

In this case, cp takes input from the txt file and copies to the new folder.

To move rather than copy, substitute mv for cp.
 
Old 01-02-2006, 11:34 AM   #3
vls
Member
 
Registered: Jan 2005
Location: The grassy knoll
Distribution: Slackware,Debian
Posts: 192

Rep: Reputation: 31
Look at the '-ok' and '-exec' options to the find command.
 
Old 01-03-2006, 12:52 AM   #4
aardwolf64
LQ Newbie
 
Registered: Jan 2006
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks for all the fish...

bigrigdriver: For some reason that didn't work right. Oh well...

vls: Thanks for pointing me in the right direction. The exec option was exactly what I was looking for. In case you're interested:

$ find . -name "*.jpg" -ok cp {} /Images \;
 
Old 01-03-2006, 12:53 AM   #5
aardwolf64
LQ Newbie
 
Registered: Jan 2006
Posts: 6

Original Poster
Rep: Reputation: 0
Hmmm... Ignore this second message. Safari gave me an error message, and I thought the first reply didn't post.

Last edited by aardwolf64; 01-03-2006 at 12:55 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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
burning and copying cds to multiple drives quercusalba Linux - Software 4 09-25-2005 12:46 AM
copying multiple files..??? krazykow Linux - Enterprise 6 09-09-2004 02:05 AM
Copying a single file to multiple directories tgolly Linux - Newbie 3 04-26-2004 04:47 PM
copying folders with spaces between? flamesrock Linux - Software 3 03-13-2004 02:49 PM
Copying complete folders cipher_arg Linux - General 2 12-17-2002 06:53 PM


All times are GMT -5. The time now is 03:12 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration