Skip to content

Instantly share code, notes, and snippets.

@seidler2547
Created March 16, 2016 15:52
Show Gist options
  • Save seidler2547/c7a5b731f0793fcdcc3f to your computer and use it in GitHub Desktop.
Save seidler2547/c7a5b731f0793fcdcc3f 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
IPADDR=192.168.22.120
TARGETFOLDER=/media/data/Pictures/A55
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