You are not logged in.
I want to copy the contents of a large directory structure to a single directory. I'm trying to use the "cp -r" command, but it copies the directory structure to the target directory.
Is there a way to do this in a single command:
cp /pictures/wedding/wed01.jpg /mypictures/
cp /pictures/wedding/wed02.jpg /mypicutres/
cp /pictures/party/party01.jpg /mypictures/
cp /pictures/morning/morning01.jpg /mypictures/
I actually want to copy *all* the jpg files in each different subdirectory to a single target directory.
Any suggestions?
thx!
Offline
Hi whol.
Use the 'find' command with backticks to create a list:
cp `find /source-dir -name "pattern"` /target-dir
For example, to copy all the .jpg files under the pictures directory to the mypictures directory:
cp `find /pictures -name "*.jpg"` /mypictures
Regards,
Win
Offline
thanks win,
maccroni gave me another way on IRC:
(from inside the dir i want to copy)
find . -type f -exec cp {} /target/directory ;
thx!
Offline