Find and Copy All Files Matching a Pattern Into a Single Directory

By Lowell Heddings on August 9th, 2010

Have you ever needed to find all the PDF files on your drive, and organize them into one place? You could use the same technique to find all zip, tar.gz, or even MP3 files, and neatly organize them into folders.

Assuming the ZIP file scenario, you could use this command to find all zip files and move them into folder inside your home directory:

find . -type f -iname '*.zip' -exec cp {} ~/zip/ ;

The -type parameter says to only find files, the -iname looks for files in a case-insensitive way, and -exec copies the files into a folder.

Lowell Heddings, better known online as the How-To Geek, spends all his free time bringing you fresh geekery on a daily basis. You can follow him on if you'd like.

  • Published 08/9/10
More Articles You Might Like

Enter Your Email Here to Get Access for Free:

Go check your email!