Skip to content

Instantly share code, notes, and snippets.

@Akasurde
Created November 23, 2022 11:57
Show Gist options
  • Save Akasurde/1e88dc81e4e7e7b545faa6e102f717d1 to your computer and use it in GitHub Desktop.
Save Akasurde/1e88dc81e4e7e7b545faa6e102f717d1 to your computer and use it in GitHub Desktop.
#!/bin/sh
rfolder=/mnt/sdcard/DCIM/Camera
adb shell ls "${rfolder}" > android.files
lfolder=/Volumes/data/documents/personal/camera
ls -1 "${lfolder}" > 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
script_dir=$(pwd)
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 < "${script_dir}"/update.files
lines=$(wc -l "${script_dir}"/update.files | awk '{ print $1 }')
echo "${lines} files copied."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment