View Full Version : Linux Help
06-20-2005, 08:45 PM
Anyone know of the command line for copying all files of a certain extension inside a folder and all its sub directories to another location while maintaining the directory tree? Thanks in advance.
06-20-2005, 08:50 PM
maybe something like this..
cp /dir/*.mp3 /whereyouwantittogo
that * means everything with the extension .mp3
06-21-2005, 07:53 AM
you will want to use
cp -r /sourcedirectory /targetdirectory
the r option tells it to copy recursively in that directory so it will grab all the sub directorys and then copy the entire structure to whatever target directory you specify
06-21-2005, 03:11 PM
Okay, it will copy the entire folder, but what I want to do is copy only certain files of a certain extension.
So in directory /usr/home/me/bigProject, I want to copy all files of extension *.m to location /usr/home/me/bigProjectBackup, while preserving the relative location of files.
06-22-2005, 05:48 AM
Ahh I see. It would probably be easier to just copy everything and then do a recursive search/delete for all files that you don't want.
06-22-2005, 10:49 PM
Yeah, that's what I told the boss. Let's say I have a very stubborn boss. Thanks for the help, I wrote a program "amv" that uses a bunch of system calls to get the job done.
On the off chance anyone else may find it useful, I will post the link on this thread at a later point in time.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.