adb push only if file doesn't exist or has changed

adb

Solution

The best way to do this is to first check if the file exists and if it does then sync it and if it does not then push.

Skeleton for a batch script to do this:

FILENAME_RESULT=$(adb shell ls / | tr -d '\015'|grep '^fileName$')
if [ -z "$FILENAME_RESULT" ];
then
    REM adb push because the file was not found
else
    REM adb sync because the file was found
fi

Problem

For a program I am using ADB to transfer a file from the computer to mobile phone. Using `adb push` overwrites every existent file and thus takes ages to finish. `adb sync` does only push the file if it exists on the phone AND contains other data than the local version. Is there any midway solution? I want the file to be transferred if it doesn't exist or is changed, but not, if it is the same as on the computer. Is there a way to achieve this?

Original source