Skip to content

Instantly share code, notes, and snippets.

@rempargo
Forked from seidler2547/flashair-download.sh
Last active December 16, 2020 11:56
Show Gist options
  • Save rempargo/5f57901e7ebb06ba88e891a4520804e8 to your computer and use it in GitHub Desktop.
Save rempargo/5f57901e7ebb06ba88e891a4520804e8 to your computer and use it in GitHub Desktop.
Script to download all pictures from a FlashAir SD card in STA mode to a specific folder on the hard drive
#!/bin/bash
# you might need cadaver
# brew install cadaver
IPADDR=192.168.39.171
TARGETFOLDER=~/Desktop/machine_1
while :; do
while ! ping -c3 -W3 -q $IPADDR ; do sleep 10 ; done
echo ls | cadaver http://$IPADDR/DCIM > /tmp/listing
awk '/^Coll: / { print $2 }' < /tmp/listing | while read FOLDER ; do
DATF=$(echo $FOLDER | cut -c5-)
YEAR=201$(echo $FOLDER | cut -c4)
TGT=$YEAR/$DATF
TDIR=$TARGETFOLDER/$TGT
echo getting $FOLDER to $TDIR
[ -d $TDIR ] || mkdir -p $TDIR
cd $TDIR
echo ls | cadaver http://$IPADDR/DCIM/$FOLDER | tee | awk '/^ / { print $1 }' | while read FILE ; do
echo Getting $FILE to $PWD/$FILE
[ -s $FILE ] || echo GET $FILE | cadaver http://$IPADDR/DCIM/$FOLDER
done
cd -
done
sleep 30
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment