Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy directories 2

Status
Not open for further replies.

sethu

Programmer
Apr 15, 2000
29
US
Hi Gurus,

I need your help badly. I want to do this.

Have a directory called IMAGES and under that several sub directories. These subdirectories have images in it with .jpg format. I need to achieve this.

Search for a file named myimage.jpg (same file exist in many sub directories)from the subdirectories and then copy all the subdirectories including the myimage.jpg file (may have some other .jpg images too which I don't need) to another directory named OLDIMAGES.

--Sethu
 
Let me get this straight you want to archive a directory called IMAGES? The directory has sub directries which have images in them.
Is using tar to archive the files a problem?
 
Hi Markman,

I want to archive the subdirectories having images called myimage.jpg only. I don't need any other files in those subdirectories if some exists.

--Sethu
 
My first thought is to perform a mass copy of the .jpg's into a clean directory tree and then archive the directory tree. If this is a common practice to mix images with other files, ( I prefer to keep images in designated image directories, just to avoid this problem ) and since your a programmer, I would write a script to search/collect and relocate the files into a clean directory and then delete the files once the files have been archived. I may be wrong, but ufsdump and tar used to archive files are not that smart to distinguish one type of file from the other.
 
To put all jpg's into a tar file named "images.jpg" you can try a simple thing like:

#find . -type f -name "*.jpg" -depth -exec tar rf images.tar {} \;

Run from top directory.

Hope it helps,

Carlos Almeida,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top