127

I have a folder in my SD Card as: /mnt/sdcard/Folder1/Folder2/Folder3/*.jpg

The name of Folder1 and Folder2 remains constant and inside Folder2 I have Folder3, 4, 5 and so on.. I want to pull all the jpeg files rather than all files (there are more) using adb to my current directory on the computer..

Every folder has different number of jpeg files and other files and I tried using this:

adb pull mnt/sdcard/Folder1/Folder2/Folder/*.jpg .

But it didn't work.. So uhmm how do I adb pull all files present in any folder of SD Card with a single command (single command because each folder has different number of files)

Hafez Divandari
  • 8,381
  • 4
  • 46
  • 63
riteshtch
  • 8,629
  • 4
  • 25
  • 38
  • Are you in Linux or Windows? This can we solved with a simple script? – Jared Burrows Apr 07 '12 at 02:04
  • Hmm i have the Android Developement Stuff installed on both: Win7 as well as Ubuntu .. if there is solution for both then well and good..! But in reality i need it only for Ubuntu (installed as a VM) .. so uhmm yeah im on Ubuntu.. – riteshtch Apr 08 '12 at 00:47
  • can you please mark a correct answer for this question? – Jared Burrows Apr 08 '15 at 22:31

7 Answers7

172

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.

Jared Burrows
  • 54,294
  • 25
  • 151
  • 185
  • 14
    `adb pull /sdcard` to pull all! – Ian Vaughan Dec 08 '15 at 19:34
  • @IanVaughan that is a command I use often and works for me but I do wish there was a way to pull everything off the sd card but exclude one of the sub paths – GµårÐïåñ Feb 08 '16 at 01:11
  • I wonder if Android has `tar`? A simple tarpipe over ADB would allow very fine-grained pulling of files, metadata, but with exclusions. If gzip/bzip2 is also on there, then a compressed tarpipe would be available :) – Mark K Cowan Apr 30 '16 at 23:14
  • For _modern_ versions of `adb` you can just specify the directory and the tool will recursivly pull everything for you – DirkyJerky Jun 30 '16 at 19:08
  • @mark-k-cowan adb backup with shared (sdcard) is plenty of bugs. – Smeterlink Dec 08 '17 at 13:20
  • If you need more customization of the pull operation, you can use a Python script that lists the folders/files then executes each one's transfer independently -- meaning you can add custom logic for deciding which ones to proceed with. I use `adb-sync` for this (with source changes/customizations): https://stackoverflow.com/a/57138127/2441655 – Venryx Jul 22 '19 at 01:29
  • 4
    `adb pull -a -p /sdcard` to pull all, show progress and **preserve timestamp**! – Unknown123 Feb 26 '20 at 13:35
  • It seems like the latest version `31.0.3 (August 2021)` doesn't require `-p` switch to show progress. I don't know since when. But it will always show on default at the moment. – Unknown123 Nov 05 '21 at 02:33
  • how can we push all folders from current directory in windows to android just like this pull command I have tried with batch scriting with `for /r %i in (*) do adb push %i storage/emulated/0` and creating zip but I am looking for more easy solution just like this pull one @JaredBurrows – Mithson Jul 09 '22 at 08:39
  • Only double slash at the beginning of the path worked for me, like this: `"//sdcard/..."` – Mercury Dec 17 '22 at 23:35
74

Directory pull is available on new android tools. ( I don't know from which version it was added, but its working on latest ADT 21.1 )

adb pull /sdcard/Robotium-Screenshots
pull: building file list...
pull: /sdcard/Robotium-Screenshots/090313-110415.jpg -> ./090313-110415.jpg
pull: /sdcard/Robotium-Screenshots/090313-110412.jpg -> ./090313-110412.jpg
pull: /sdcard/Robotium-Screenshots/090313-110408.jpg -> ./090313-110408.jpg
pull: /sdcard/Robotium-Screenshots/090313-110406.jpg -> ./090313-110406.jpg
pull: /sdcard/Robotium-Screenshots/090313-110404.jpg -> ./090313-110404.jpg
5 files pulled. 0 files skipped.
61 KB/s (338736 bytes in 5.409s)
Palani
  • 8,962
  • 11
  • 53
  • 62
  • 1
    I tried this, but it only pulled some directories. Not sure what its criteria was. – acjay Jan 09 '14 at 16:43
  • 2
    If you want to pull a folder owned by _root_, start an `adb` root session (using `$ adb root`). – MasterAM Jun 12 '14 at 13:32
  • run the command as root just like @MasterAM said! worked without a problem! cheers! – Migisha Feb 13 '15 at 05:41
  • @acjay Empty folders are omitted. This is also true of recursive folders that are ultimately empty. E.g. `/sdcard/folder1/folder2` will result in `folder1` being omitted if `folder2` is empty and there are no other files under `folder1`. – MDMower May 14 '15 at 20:48
47

Please try with just giving the path from where you want to pull the files I just got the files from sdcard like

adb pull sdcard/

do NOT give * like to broaden the search or to filter out. ex: adb pull sdcard/*.txt --> this is invalid.

just give adb pull sdcard/

Gruber
  • 2,196
  • 5
  • 28
  • 50
Ilavarasan
  • 469
  • 4
  • 3
6

Yep, just use the trailing slash to recursively pull the directory. Works for me with Nexus 5 and current version of adb (March 2014).

3

On Android 6 with ADB version 1.0.32, you have to put / behind the folder you want to copy. E.g adb pull "/sdcard/".

antimatter
  • 855
  • 7
  • 10
3

If you want to pull a directory with restricted access from a rooted device you need to restart adb as root: type adb root before pull. Otherwise you'll get an error saying remote object '/data/data/xxx.example.app' does not exist

naXa stands with Ukraine
  • 35,493
  • 19
  • 190
  • 259
  • Don't forget to set ADB root access in developer actions otherwise you'll get this error `ADB Root access is disabled by system setting - enable in Settings -> System -> Developer options` – sneaky Sep 03 '22 at 12:35
1

if your using jellybean just start cmd, type adb devices to make sure your readable, type adb pull sdcard/ sdcard_(the date or extra) <---this file needs to be made in adb directory beforehand. PROFIT!

In other versions type adb pull mnt/sdcard/ sdcard_(the date or extra)

Remember to make file or your either gonna have a mess or it wont work.

EDward
  • 11
  • 1