Created
April 14, 2014 13:42
-
-
Save irq0/10649156 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 | |
URL="http://doxieflashair.local" | |
DIRS="/DCIM/100DOXIE" | |
list () { | |
curl -s "${URL}/command.cgi?op=100&DIR=${1}" \ | |
| awk 'BEGIN { FS=","; OFS="/" } /.+,(.+,){3}/ { print $1,$2 }' | |
} | |
files () { | |
for dir in $1; do | |
list "$dir" | |
done | |
} | |
download () { | |
files=$@ | |
for file in $files; do | |
echo -n "$file: " | |
mkdir -p "./$(dirname $file)" | |
if curl -s -o "./${file}" "${URL}/${file}"; then | |
echo "OK" | |
else | |
echo "FAIL" | |
fi | |
done | |
} | |
download $(files $DIRS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment