Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - General
User Name
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.


  Search this Thread
Old 01-02-2006, 10:23 AM   #1
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, 10:32 AM   #2
LQ Addict
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,891

Rep: Reputation: 351Reputation: 351Reputation: 351Reputation: 351
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, 10:34 AM   #3
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-02-2006, 11:52 PM   #4
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-02-2006, 11:53 PM   #5
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-02-2006 at 11:55 PM.


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-24-2005 11:46 PM
copying multiple files..??? krazykow Linux - Enterprise 6 09-09-2004 01:05 AM
Copying a single file to multiple directories tgolly Linux - Newbie 3 04-26-2004 03:47 PM
copying folders with spaces between? flamesrock Linux - Software 3 03-13-2004 01:49 PM
Copying complete folders cipher_arg Linux - General 2 12-17-2002 05:53 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:49 PM.

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