0

I have the following command and output:

    d:\adb>adb shell service call iphonesubinfo 1
Result: Parcel(
  0x00000000: 00000000 0000000f 00350033 00380039 '........8.5.9.8.'
  0x00000010: 00320037 00360030 00350032 00310034 '7.2.0.1.2.4.4.1.'
  0x00000020: 00390039 00000039                   '5.9.9...        ')

how can I parse it and get only the IMEI in one line ?

also :

< waiting for device >
...
(bootloader) ---------------------------------------------------------
(bootloader) Device-ID
(bootloader) 2FC9A68923FD175AA6E13657181CA6AB
(bootloader) 4AE438F12376AFA85D0E3467AE83A752
(bootloader) ---------------------------------------------------------
OKAY [  0.020s]
finished. total time: 0.020s

get the serial as: 2FC9A68923FD175AA6E13657181CA6AB4AE438F12376AFA85D0E3467AE83A752

Gurman Eduard
  • 73
  • 1
  • 1
  • 8

1 Answers1

3

Please note my REM comments in the "code"

@echo off
REM Spliting the IMEI multiline output to lines
SETLOCAL ENABLEDELAYEDEXPANSION
SET count=1
FOR /F "tokens=* USEBACKQ" %%F IN (`adb shell service call iphonesubinfo 1`) DO (
  SET var!count!=%%F
  SET /a count=!count!+1
)

REM From each output line of interest we take the IMEI "string" portion 
for /f "tokens=6" %%G IN ("%var2%") DO SET v1=%%G
for /f "tokens=6" %%G IN ("%var3%") DO SET v2=%%G
for /f "tokens=4" %%G IN ("%var4%") DO SET v3=%%G

REM Stiching the IMEI parts to one string
SET imei=%v1%%v2%%v3%
SET imei=%imei:'=%
SET imei=%imei:.=%
ECHO %imei%

ENDLOCAL
Shmil The Cat
  • 4,548
  • 2
  • 28
  • 37