Skip to content

Instantly share code, notes, and snippets.

@DagW
Last active March 2, 2018 19:04
Show Gist options
  • Save DagW/5c07c275c405b751f03dc18326d3fdee to your computer and use it in GitHub Desktop.
Save DagW/5c07c275c405b751f03dc18326d3fdee to your computer and use it in GitHub Desktop.
Sync *lots* of camera photos from your android phone to a local folder. Can be resumed!
#!/bin/sh
rfolder=/sdcard/DCIM/Camera
lfolder=Images
adb shell ls "$rfolder" > android.files
ls "$lfolder" -1 > local.files
rm -f update.files
touch update.files
while IFS= read -r q; do
# Remove non-printable characters (are not visible on console)
l=$(echo ${q} | sed 's/[^[:print:]]//')
# Populate files to update
if ! grep -q "$l" local.files; then
echo "$l" >> update.files
fi
done < android.files
cd $lfolder
while IFS= read -r q; do
# Remove non-printable characters (are not visible on console)
l=$(echo ${q} | sed 's/[^[:print:]]//')
echo "Get file: $l"
adb pull "$rfolder/$l"
done < ../update.files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment