我如何adb拉出SD卡中存在的文件夹的所有文件

rit*_*t93 103 android android-sdcard

我的SD卡中有一个文件夹:/mnt/sdcard/Folder1/Folder2/Folder3/*.jpg

Folder1和Folder2的名称保持不变,在Folder2里面我有Folder3,4,5等等.我想把所有jpeg文件而不是所有文件(还有更多)用adb到我当前的计算机目录上.

每个文件夹都有不同数量的jpeg文件和其他文件,我尝试使用这个:

adb pull mnt/sdcard/Folder1/Folder2/Folder/*.jpg .
Run Code Online (Sandbox Code Playgroud)

但它没有用..所以我怎么用一个命令adb拉出SD卡的任何文件夹中的所有文件(单个命令因为每个文件夹有不同数量的文件)

Jar*_*ows 128

单个文件/文件夹使用pull:

adb pull "/sdcard/Folder1"
Run Code Online (Sandbox Code Playgroud)

输出:

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.
Run Code Online (Sandbox Code Playgroud)

使用find来自的特定文件/文件夹BusyBox:

adb shell find "/sdcard/Folder1" -iname "*.jpg" | tr -d '\015' | while read line; do adb pull "$line"; done;
Run Code Online (Sandbox Code Playgroud)

这是一个解释:

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.
Run Code Online (Sandbox Code Playgroud)

脚本将从顶部文件夹开始,递归地向下查找所有"*.jpg"文件,并将它们从手机中拉到当前目录.

  • `adb pull/sdcard`拉全部! (9认同)
  • `adb pull -a -p /sdcard` 拉取所有内容,显示进度并**保留时间戳**! (6认同)

Pal*_*ani 70

目录拉动可用于新的Android工具.(我不知道它是从哪个版本添加的,但它在最新的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)
Run Code Online (Sandbox Code Playgroud)

  • 如果你想拉一个_root_拥有的文件夹,启动一个`adb`根会话(使用`$ adb root`). (2认同)

小智 39

请尝试只提供你想从哪里拉文件的路径我刚刚从SD卡中获取文件

adb pull sdcard/

不要*喜欢扩大搜索范围或过滤掉.例如:adb pull sdcard/*.txt - >这是无效的.

刚给adb拉sdcard /

  • 请注意尾随的`/`__does__ mater. (11认同)

小智 6

是的,只需使用尾部斜杠递归拉取目录.适用于Nexus 5和当前版本的adb(2014年3月).