How to Copy Selected Files from Android with Adb Pull

How to copy selected files from Android with adb pull

You can move your files to other folder and then pull whole folder.


adb shell mkdir /sdcard/tmp
adb shell mv /sdcard/mydir/*.jpg /sdcard/tmp # move your jpegs to temporary dir
adb pull /sdcard/tmp/ # pull this directory (be sure to put '/' in the end)
adb shell mv /sdcard/tmp/* /sdcard/mydir/ # move them back
adb shell rmdir /sdcard/tmp # remove temporary directory

adb pull multiple files

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

Android: adb pull file on desktop

Use a fully-qualified path to the desktop (e.g., /home/mmurphy/Desktop).

Example: adb pull sdcard/log.txt /home/mmurphy/Desktop

How to transfer files from Phone to PC using ADB?

Use the following command:

adb pull /storage/sdcard0/pictures/screenshots/ C:\Users\<username>\Downloads

You will find the folder named 'screenshots' at the location C:\Users\<username>\Downloads

adb pull multiple files with the same extension

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

See adb pull multiple files

How do I adb pull ALL files of a folder present in SD Card

Single File/Folder using pull:

adb pull "/sdcard/Folder1"

Output:

adb pull "/sdcard/Folder1"
pull: building file list...
pull: /sdcard/Folder1/image1.jpg -> ./image1.jpg
pull: /sdcard/Folder1/image2.jpg -> ./image2.jpg
pull: /sdcard/Folder1/image3.jpg -> ./image3.jpg
3 files pulled. 0 files skipped.

Specific Files/Folders using find from BusyBox:

adb shell find "/sdcard/Folder1" -iname "*.jpg" | tr -d '\015' | while read line; do adb pull "$line"; done;

Here is an explanation:

adb shell find "/sdcard/Folder1" - use the find command, use the top folder
-iname "*.jpg" - filter the output to only *.jpg files
| - passes data(output) from one command to another
tr -d '\015' - explained here: http://stackoverflow.com/questions/9664086/bash-is-removing-commands-in-while
while read line; - while loop to read input of previous commands
do adb pull "$line"; done; - pull the files into the current running directory, finish. The quotation marks around $line are required to work with filenames containing spaces.

The scripts will start in the top folder and recursively go down and find all the "*.jpg" files and pull them from your phone to the current directory.



Related Topics



Leave a reply



Submit