BlogPhotosContact

Topics

Recursive copy with pattern match on Unix

For a new online shop I am working on, I needed to copy all the products images from the old site to the new one. The challenge is that both sites don't run on the same server and a product can have multiple images which are stored in different subdirectories. Furthermore, I am not interested in copying thumbnails since those will be regenerated with better quality and probably different format.

In order to perform such a copy, recursive and using a filter, here is what I found on the net:

$ tar -cf - `find . -name "*_xl.jpg" -print` | ( cd ../dest tar xBf - )

This will recusively copy all my *_xl.jpg files into a ../dest directory, while also creating the subdirectories when needed. Perfect !

Comments (0)  Permalink

Comments

Add a comment

The Trackback URL to this comment is:
http://golgote.freeflux.net/blog/plugin=trackback(107).xml

No new comments allowed (anymore) on this post.