Recursively copy all jpeg files to a single directory

Sat 06 February 2016

I have backups from multiple machines on one external hard drive. No I wanted to combine all pictures from those machines into one big folder, so I could easily upload them into owncloud and have one place with all our images.

This job turned out to be simple using a special shell option.

shopt -s globstar
cp **/*.jpeg /home/willem/backup

The first line enable the globstar option, which, if set, allows you to use the pattern ** in a filename expansion context. This will match all files and zero or more directories and subdirectories. (If the pattern is followed by a ‘/’, only directories and subdirectories match.)

social