Last active
March 2, 2018 19:04
-
-
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!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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