#!/bin/sh usage() { echo "Usage: copy-files.sh " echo ": directory where the files are located" echo ": directory where the files are copied to" exit 1 } if [ $# != 2 ]; then usage fi input=$1 output=$2 find "$input" -type f -iregex '.*\.\(pdf\|doc\|docx\|xlsx\|accdb|\mdb\)' -print0 | xargs -0 cp "{}" "$output"