Copying only JPG from a directory structure to another location Linux
I wish to recursively go through the folders of a directory structure and copy any .jpg I find into another directory.
I think I had the wrong idea with:
cp -R photos/*.jpg /cpjpg
How can I do this from the command line in Ubuntu?
This will copy all files ending in .jpg or .jpeg (case insensitive as well) in the current directory and all its subdirectories to the directory /cpjpg. The directory structure is not copied.
find . -type f \( -iname "*.jpg" -o -iname "*.jpeg" \) -exec cp '{}' /cpjpg \;
This preserves the directory structure:
rsync -av --include='*.jpg' --include='*/' --exclude='*' SRC DST
see http://logbuffer.wordpress.com/2011/03/24/linux-copy-only-certain-filetypes-with-rsync-from-foldertree/