Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adb pull multiple files

Tags:

android

adb

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 work:

adb pull /sdcard/gps*.trace . 
like image 896
hsz Avatar asked Jun 17 '12 20:06

hsz


People also ask

How do I push all files into a directory using ADB?

Copy the *. img files to an empty directory, then push the directory ( adb push /tmp/images /storage/sdcard0 ). adb will push all files in that directory to your designated location.


2 Answers

You can use xargs and the result of the adb shell ls command which accepts wildcards. This allows you to copy multiple files. Annoyingly the output of the adb shell ls command includes line-feed control characters that you can remove using tr -d '\r'.

Examples:

# Using a relative path adb shell 'ls sdcard/gps*.trace' | tr -d '\r' | xargs -n1 adb pull # Using an absolute path  adb shell 'ls /sdcard/*.txt' | tr -d '\r' | sed -e 's/^\///' | xargs -n1 adb pull 
like image 84
David Momenso Avatar answered Sep 29 '22 04:09

David Momenso


adb pull can receive a directory name instead of at file and it will pull the directory with all files in it.

Pull all your gps traces in /sdcard/gpsTraces

adb pull /sdcard/gpsTraces/ .  

Example of adb pull and adb push of recursive directories:

C:\Test>adb pull /data/misc/test/ . pull: building file list... pull: /data/misc/test/test1/test2/test.3 -> ./test1/test2/test.3 pull: /data/misc/test/test1/test2/test.2 -> ./test1/test2/test.2 pull: /data/misc/test/test1/test2/test.1 -> ./test1/test2/test.1 pull: /data/misc/test/test1/test.3 -> ./test1/test.3 pull: /data/misc/test/test1/test.2 -> ./test1/test.2 pull: /data/misc/test/test1/test.1 -> ./test1/test.1 pull: /data/misc/test/test.3 -> ./test.3 pull: /data/misc/test/test.2 -> ./test.2 pull: /data/misc/test/test.1 -> ./test.1 9 files pulled. 0 files skipped. 0 KB/s (45 bytes in 0.093s)  C:\Test>adb push . /data/misc/test/ push: ./test1/test2/test.3 -> /data/misc/test/test1/test2/test.3 push: ./test1/test2/test.2 -> /data/misc/test/test1/test2/test.2 push: ./test1/test2/test.1 -> /data/misc/test/test1/test2/test.1 push: ./test1/test.3 -> /data/misc/test/test1/test.3 push: ./test1/test.2 -> /data/misc/test/test1/test.2 push: ./test1/test.1 -> /data/misc/test/test1/test.1 push: ./test.3 -> /data/misc/test/test.3 push: ./test.2 -> /data/misc/test/test.2 push: ./test.1 -> /data/misc/test/test.1 9 files pushed. 0 files skipped. 0 KB/s (45 bytes in 0.062s) 
like image 41
Ofir Luzon Avatar answered Sep 29 '22 06:09

Ofir Luzon