Link to home
Start Free TrialLog in
Avatar of akapas
akapas

asked on

Copying files with the same extension from a folder with subfolders

Hi,

I'd like to copy all the pdfs that reside within all the folders withing one folder.I tried this, but it didn;t work. It says 'no match'.

cp -r /Users/desiree/Library/Page\ Sender/In/*.pdf /Users/desiree/Desktop/Pdfs

The computer is an OS X machine not Linux, but that didn't seem to matter much with other commands. :-)

Any ideas?

Thanks,
agi
Avatar of Karl Heinz Kremer
Karl Heinz Kremer
Flag of United States of America image

find . -name "/Users/desiree/Library/Page\ Sender/In/*pdf" -exec cp {} /Users/desiree/Desktop/Pdfs \;

The copy command does not recursively copy files, you need to call find first to search for all PDF files, and then copy the files that were found.

Cut&paste error... Sorry about this.

find "/Users/desiree/Library/Page Sender/In" -name "*pdf" -exec cp {} /Users/desiree/Desktop/Pdfs \;
Avatar of akapas
akapas

ASKER

Thanks, but didn't work. It says "No such file or directory".

Agi
ASKER CERTIFIED SOLUTION
Avatar of Karl Heinz Kremer
Karl Heinz Kremer
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of akapas

ASKER

Sorry, I'm still new here, wasn't sure how to accept.
Avatar of akapas

ASKER

Thanks. :-)