Created
February 8, 2017 09:43
-
-
Save devpg/e224a8ea406ee87b5c6d2cd4b70d768c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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