Android - How to pull only newer files with “adb pull”? (Android SDK utility)

As described by ss-3-1415926535897932384626433 there is no flag, but you have to get a list of files first and then check if your local files match. I wrote a little script for it:

#!/bin/sh

rfolder=/sdcard/DCIM/Camera
lfolder=Camera

adb shell ls "$rfolder" > android.files

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

Adjust the remote folder rfolder and the local folder lfolder to locations of your own choice.


adb-sync - small, yet powerfull python script that can do all your asked and more... https://github.com/google/adb-sync


adb pull doesn't seem to provide a flag to pull selected files.

As a workaround, you can do this: Use adb shell [Unix shell command] to copy selected files to a temporary location and then pull all files from that location.

Update:
You can use cp -u [source] [destination] unix shell command to copy only modified files on subsequent run. You can also use -r flag to use it on subdirectories recursive, if its required.

Tags:

Adb