hsz hsz - 3 months ago 113
Android Question

adb pull multiple files

What is the best way to pull multiple files using

adb pull


I have on my
/sdcard/
25 files with following name:

gps1.trace
gps2.trace
...
gps25.trace


Wildcard does not works:

adb pull /sdcard/gps*.trace .

Answer

You can use xargs and the result of the adb ls command that accepts wildcards. This allows you to copy multiple files. There's just a small problem from the output of the adb ls command that has to be filtered out. Annoyingly the output of the adb ls command includes line-feed control characters that you can remove using tr.

Example:

adb shell ls /sdcard/gps*.trace | tr '\r' ' ' | xargs -n1 adb pull  

or, on Windows (since the newline characters are different),

adb shell ls /sdcard/gps*.trace | tr "\n\r" " " | xargs -n1 adb pull
Comments