-
-
Save carloswalterbr/1870afe0e7baf43b5b386f541ee1eea3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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