如何通过分散文件中的cmd获取frp分区

时间:2017-03-09 09:26:07

标签: android batch-file

如何才能获得partition_index: SYS18linear_start_addr: 0x8020000physical_start_addr: 0x8020000partition_size: 0x100000

另外,scatter.txt可能因android设备型号而异。

我只需要获取scatter.txt的frp部分。

  partition_index: SYS17
  partition_name: metadata
  file_name: NONE
  is_download: false
  type: NORMAL_ROM
  linear_start_addr: 0x6020000
  physical_start_addr: 0x6020000
  partition_size: 0x2000000
  region: EMMC_USER
  storage: HW_STORAGE_EMMC
  boundary_check: true
  is_reserved: false
  operation_type: INVISIBLE
  reserve: 0x00

  partition_index: SYS18
  partition_name: frp
  file_name: NONE
  is_download: false
  type: NORMAL_ROM
  linear_start_addr: 0x8020000
  physical_start_addr: 0x8020000
  partition_size: 0x100000
  region: EMMC_USER
  storage: HW_STORAGE_EMMC
  boundary_check: true
  is_reserved: false
  operation_type: PROTECTED
  reserve: 0x00

  partition_index: SYS19
  partition_name: pad
  file_name: NONE
  is_download: false
  type: NORMAL_ROM
  linear_start_addr: 0x8120000
  physical_start_addr: 0x8120000
  partition_size: 0x6E0000
  region: EMMC_USER
  storage: HW_STORAGE_EMMC
  boundary_check: true
  is_reserved: false
  operation_type: INVISIBLE
  reserve: 0x00

2 个答案:

答案 0 :(得分:0)

@echo off&SetLocal EnableDelayEdexpansion
set /a n = 1
for /f "delims=" %%a in (scatter.txt) do (
  set "b=%%a"
  set "b=!b:partition_index=!"
  set "b=!b:linear_start_addr=!"
  set "b=!b:physical_start_addr=!"
  set "b=!b:partition_size=!"
  if not "!b!" equ "%%a" (
    if defined flag set /a n+=1
    call set str!n!=%%a
  )

  set "b=!b:partition_name: frp=!"
  if "!b!" equ "" set flag=1
)
for /l %%a in (1 1 4) do (
  echo !str%%a!
)

pause

答案 1 :(得分:0)

以下评论脚本应该完成这项工作。请注意,delims在两个for /F循环中略有不同:

@ECHO OFF
SETLOCAL EnableExtensions EnableDelayedExpansion

set "_word=%~1"                         for debugging purposes
if not defined _word set "_word=frp"    default value of partition name

set "_right="                           remove variable _right

                  REM iteration #1: GET sequence number of a data block
set "_index=0"
for /F "tokens=1,* delims=: " %%G in ('
    findstr /R "partition_index partition_name" "D:\bat\SO\files\scatter.txt"
    ') do (
  if "%%~G"=="partition_index" set /A _index+=1
  if "%%~G"=="partition_name" if "%%~H"=="%_word%" set /A _right=_index  
)

if not defined _right (
    echo %_word% not found as partition_name
    goto :endscript
)

                  REM iteration #2: USE sequence number of a data block
set "_index=0"
for /F "tokens=1,* delims=:" %%G in ('
    findstr /R "partition linear physical" "D:\bat\SO\files\scatter.txt"
    ') do (
  if "%%~G"=="partition_index" set /A _index+=1
  if %_right% EQU !_index! echo %%G:%%H

)
:endscript
ENDLOCAL
goto :eof

<强>输出

==> D:\bat\SO\42691448.bat xxx
xxx not found as partition_name

==> D:\bat\SO\42691448.bat metadata
partition_index: SYS17
partition_name: metadata
linear_start_addr: 0x6020000
physical_start_addr: 0x6020000
partition_size: 0x2000000

==> D:\bat\SO\42691448.bat
partition_index: SYS18
partition_name: frp
linear_start_addr: 0x8020000
physical_start_addr: 0x8020000
partition_size: 0x100000

==>

资源(必读):