Skip to content

Instantly share code, notes, and snippets.

@evmn
Last active May 18, 2023 17:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save evmn/0a68c4fc141eac8b2a9baf3e09c4890c to your computer and use it in GitHub Desktop.
Save evmn/0a68c4fc141eac8b2a9baf3e09c4890c to your computer and use it in GitHub Desktop.
#/bin/bash
declare -a remote_dirs=("sdcard/inshot/"
"sdcard/DCIM/"
"sdcard/Pictures/"
"sdcard/Download"
"sdcard/Movies/")
bak=bak_$(date +"%Y%m%d-%H%M%S")
for dir in "${remote_dirs[@]}"
do
# adb shell du -a "$dir" | awk '/\.(png|PNG|jpg|JPG|mp4|MP4)$/{print $2}' >> $bak
adb shell find "$dir" -type f -iname "*.mp4" -or -iname "*.jpg" -or -iname "*.png" >> $bak
done
sed -i '/\/\./d' $bak
while IFS= read -r remote
do
local=$(echo "$remote" | awk -F"/" '{OFS="/"; $1=$NF=""; print}' | sed 's/^\///')
if [ ! -d "$local" ]; then
echo "mkdir -p $local"
echo "mkdir -p $local" | bash
fi
media=$(echo "$remote" | awk -F"/" '{OFS="/"; $1=""; print}' | sed 's/^\///')
if [ ! -f "$media" ]; then
echo "adb pull \"$remote\" \"$local\""
echo "adb pull \"$remote\" \"$local\"" | bash
fi
# echo "adb shell rm \"$remote\""
# echo "adb shell rm \"$remote\"" | bash
done < $bak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment