Find JPG Files in Directory and CP (copy) to another directory

Hold on Cowboy

This blog post is pretty old. Be careful with the information you find in here. It's likely dead, dying, or wildly inaccurate.

Today I was faced with the challenge of finding all the JPG files in a directory (and subdirectories of that) and copying them to another directory (striping out the subdirectory folder name).

find /path/to/directory/ -iname "*.jpg" -exec cp '{}' /path/to/dest/dir/ \;

That did it perfectly.

Keywords Find Folder Strip Path Copy cp directory

Reference: http://www.linuxquestions.org/questions/linux-newbie-8/shell-script-to-search-and-copy-jpg-to-another-folder.-730320/

Did this help you out? It took me a few days to piece together all this information together, I hope this saves you some time (who knows, maybe the future me will be thankful I wrote this down). Let me know your thoughts. [email protected]