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

标签 android android-sdcard

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

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

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

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

但它没有工作.. 那么嗯,我如何使用单个命令 adb 拉取 SD 卡的任何文件夹中存在的所有文件(单个命令,因为每个文件夹具有不同数量的文件)

最佳答案

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

adb pull "/sdcard/Folder1"

输出:

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.

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

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

这里有一个解释:

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.

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

关于android - 我如何 adb 拉出 SD 卡中存在的文件夹的所有文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10050925/

相关文章:

android - 在 KitKat 4.4.2 中获取 SDard(s) 路径和大小

java - 将电影文件保存在特定文件夹中 -android-

android - OutputStreamWriter 不追加

android - 在启动画面期间加载 MainActivity

c# - 异步/等待 Android 下的不良做法?

android - 如果 android 中的互联网连接速度慢,则显示警报消息

android - 如何在android模拟器中增加sd卡内存?

java - android.system.ErrnoException 错误

android - 如何导出所有 firebase 远程配置键和值?

android - 华为应用市场发布版6003错误码