0

I am trying to use ADB to pull files based on their filename containing certain characters. Phone is not rooted HTC One. PC is Windows 7.

I found this question: adb pull multiple files

The original code in that thread was:

adb shell ls /sdcard/gps*.trace | tr "\n\r" " " | xargs -n1 adb pull

I have modified it to:

ADB shell ls /mnt/sdcard/dcim/100Media/IMAG07* | tr "\r\n" " " | xargs -n1 adb pull \HTC2

When I run the code, I get an error that "'tr' is not recognized as an internal or external command, operable program or batch file."

What am I doing wrong? Thank you in advance!

Community
  • 1
  • 1
luv951
  • 1
  • 1

2 Answers2

1

There's no build-in "tr" or "xargs" command in windows. Here's my working batch script for windows. Modify the pattern and save it as a ***.bat file, copy it to the local directory(in your case the HTC2 folder), and double click it or run it in the cmd window in this folder.

pull_multiple_files

@echo off
rem ======== Modify this line to your pattern =====
adb shell ls /sdcard/*.png >_temp
rem =================================================

setlocal EnableDelayedExpansion
for /f %%i in (_temp) do (
    echo %%i>_temp
    set /p file=<_temp
    echo pulling file: !file!
    adb pull !file!
)
setlocal DisableDelayedExpansion
del _temp
wrkwrk
  • 2,261
  • 15
  • 21
  • Thank you for the help! Unfortunately, I can't get it to work. Here is exactly what I am using: `@echo off rem ======== Modify this line to your pattern ===== C:\Users\Dan\AppData\Local\Android\sdk1\platform-tools\adb shell ls /mnt/sdcard/dcim/100Media/IMAG07*.jpg >_temp rem ================================================= setlocal EnableDelayedExpansion for /f %%i in (_temp) do ( echo %%i>_temp set /p file=<_temp echo pulling file: !file! adb pull !file! ) setlocal DisableDelayedExpansion del _temp ` – luv951 Jul 22 '15 at 15:32
  • run C:\Users\Dan\AppData\Local\Android\sdk1\platform-tools\adb shell ls /mnt/sdcard/dcim/100Media/IMAG07*.jpg in the cmd windows, what is the output? @luv951 – wrkwrk Jul 23 '15 at 02:31
  • The output is a list of all my jpg files between 700 and 799. – luv951 Jul 23 '15 at 15:11
0

Thank you for the help! I figured out what I was doing to make your code work. I am very new to this (5 days ago downloaded SDK for the first time) so it took a bit for me to work through the code. I added cmd \k at the end so the command prompt would stay open and I could verify what it had done.

rem@echo off
rem ======== Modify this line to your pattern =====
C:\Users\Neil\AppData\Local\Android\sdk1\platform-tools\adb shell ls /mnt/sdcard/dcim/100Media/IMAG09*.jpg >_temp
rem =================================================

setlocal EnableDelayedExpansion
for /f %%i in (_temp) do (
    echo %%i>_temp
    set /p file=<_temp
    echo pulling file: !file!
    C:\Users\Dan\AppData\Local\Android\sdk1\platform-tools\adb pull !file! 
)
setlocal DisableDelayedExpansion
del _temp
cmd /k
luv951
  • 1
  • 1