SEARCH

How-To Geek

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

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

Comments (1)

  1. in “use this command to find all zip files and move them into folder inside your home directory” you might want to change the word move to copy.

    change -exec cp to -exec mv to do a move.

Enter Your Email Here to Get Access for Free:

Go check your email!