Skip to content

Instantly share code, notes, and snippets.

@devpg
Created February 8, 2017 09:43
Show Gist options
  • Save devpg/e224a8ea406ee87b5c6d2cd4b70d768c to your computer and use it in GitHub Desktop.
Save devpg/e224a8ea406ee87b5c6d2cd4b70d768c to your computer and use it in GitHub Desktop.
#!/bin/bash
echo Searching in $1
echo ... based on $2
echo ... and copying to $3
mkdir -p $3
SUFFIX="_a.jpg"
cat $2 | while read LINE
do
# Skip empty lines
if [ -z "$LINE" ]; then
continue
fi
FILE=$LINE$SUFFIX
# Search + copy file and stop after first match
find $1 -type f -name $FILE | head -n 1 | xargs -I {} cp {} $3
# Print line if item was no found
COPY=$3"/"$FILE
if [ ! -f $COPY ]; then
echo $LINE
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment