-1

Is there a method to pull via ADB the latest screenshot from my device ?

-rw-rw---- 1 root sdcard_rw  137047 2017-11-04 14:02 Screenshot_20171104-140236.png
-rw-rw---- 1 root sdcard_rw   67459 2017-11-04 14:05 Screenshot_20171104-140533.png
-rw-rw---- 1 root sdcard_rw   33939 2017-11-04 14:05 Screenshot_20171104-140557.png
-rw-rw---- 1 root sdcard_rw  329546 2017-11-06 11:12 Screenshot_20171106-111218.png
-rw-rw---- 1 root sdcard_rw  437013 2017-11-13 17:57 Screenshot_20171113-175727.png
-rw-rw---- 1 root sdcard_rw 1200088 2017-11-19 13:44 Screenshot_20171119-134405.png
-rw-rw---- 1 root sdcard_rw  146758 2017-12-12 20:19 Screenshot_20171212-201936.png
-rw-rw---- 1 root sdcard_rw  128158 2017-12-18 11:11 Screenshot_20171218-111151.png

How to pull the latest screenshot ?

-rw-rw---- 1 root sdcard_rw  128158 2017-12-18 11:11 Screenshot_20171218-111151.png

Currently i'm pulling all the files using :

adb pull /mnt/sdcard/Screenshots c:\screenshots

Then organize them by date in Windows Explorer

Edit1 I can get the latest file using :

adb shell stat -c %y /mnt/sdcard/Screenshots
M. A.
  • 424
  • 6
  • 21

2 Answers2

0

ADB doesn't support flags, so you'll have to pull all the files(names), then do some logic to find the most recent file, then pull that.

It's possible using a script, more info in this related question.

washichi
  • 100
  • 3
  • 15
0

I'd suggest capturing the output of the adb command that gets ya the latest file and redirecting that to an adb command that does the pulling.

Based off a somewhat related answer for saving the output of a command to a variable...

FOR /F "tokens=* USEBACKQ" %%F IN (`command`) DO (
    SET var=%%F
)

... replace command with the command's output to be captured, then...

adb pull %var% c:\screenshots

... or...

adb pull /mnt/sdcard/Screenshots/%var% c:\screenshots

... should do kinda what ya want.

S0AndS0
  • 860
  • 1
  • 7
  • 20