Add search by extension capabilities to copy-files

This commit is contained in:
coolneng 2021-04-29 14:10:53 +02:00
parent 84082d85b0
commit f578383b63
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
1 changed files with 4 additions and 6 deletions

View File

@ -1,8 +1,8 @@
#!/bin/sh
usage() {
echo "Usage: copy-files.sh <file> <output directory>"
echo "<file>: file that contains the files to copy, each on a different line"
echo "Usage: copy-files.sh <input directory> <output directory>"
echo "<input directory>: directory where the files are located"
echo "<output directory>: directory where the files are copied to"
exit 1
}
@ -11,9 +11,7 @@ if [ $# != 2 ]; then
usage
fi
filename=$1
input=$1
output=$2
while read -r p; do
cp "$p" "$output"
done <"$filename"
find "$input" -type f -iregex '.*\.\(pdf\|doc\|docx\|xlsx\|accdb|\mdb\)' -print0 | xargs -0 cp "{}" "$output"