对于一个程序,我使用 ADB 将文件从计算机传输到手机。
使用会adb push
覆盖每个现有文件,因此需要很长时间才能完成。
adb sync
仅当文件存在于手机上且包含本地版本以外的其他数据时才推送该文件。
有没有中途解决办法?如果文件不存在或已更改,我希望传输该文件,但如果该文件与计算机上的相同,则不传输该文件。有办法实现这一点吗?
adb push --sync /local/file /sdcard/remote/file
Run Code Online (Sandbox Code Playgroud)
从adb --help
adb push [--sync] [-zZ] LOCAL... REMOTE copy local files/directories to device --sync: only push files that are newer on the host than the device. -z: enable compression -Z: disable compression
小智 3
最好的方法是首先检查文件是否存在,如果存在则同步它,如果不存在则推送。
用于执行此操作的批处理脚本的骨架:
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
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
13661 次 |
最近记录: |