2012-10-25

Recursively copy all PDF files from a directory tree to a single directory

Someone gave me a bunch of PDF files spread out through multiple subdirectories and I needed to get them all into a single directory.

In Mac OS X (and probably Linux) this will scan through the directory specified and its subdirectories and copy all of the PDF files to the target directory:

find /Users/joedokes/Desktop/source_directory -name "*.pdf" -exec cp {} /Users/joedokes/Desktop/target_directory \;


2 comments:

wari said...

On linux, it should look like this:

find /path -name "*.pdf" -exec cp {} /dest_path \;

Omitting the '-name' and '*' will fail to get what you want.

AndyfromTucson said...

Thanks for the correction wari!