Skip to content

Instantly share code, notes, and snippets.

@Hackbard
Forked from irq0/download_flashair
Created June 30, 2019 13:36
Show Gist options
  • Save Hackbard/4e64a8340af735707c2dc38056ae093c to your computer and use it in GitHub Desktop.
Save Hackbard/4e64a8340af735707c2dc38056ae093c 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