Skip to content

Instantly share code, notes, and snippets.

@irq0
Created April 14, 2014 13:42
Show Gist options
  • Save irq0/10649156 to your computer and use it in GitHub Desktop.
Save irq0/10649156 to your computer and use it in GitHub Desktop.
#!/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