回复 31# hentai87
for 中可以给变量添加很多你需要的附加参数,用#分隔
我帮你添加了本地文件路径和远程apk路径,其它的你自由发挥- @echo off
- setlocal enabledelayedexpansion
- REM 记录已备份的apk
- for /f "tokens=1,2* delims=_" %%i in ('dir /b .\bak\*_*_*.apk') do set "#%%~nk=已备份#未安装#%%i_%%j_%%k"
- REM 记录已安装的apk
- for /f "tokens=1-3* delims=:=" %%i in ('adb shell pm list packages -f -a') do (
- if "%%l"=="" (
- if "!#%%k!"=="" (
- set "#%%k=未备份#已安装#_#%%j"
- ) else (
- set "#%%i=已备份#已安装!#%%k:~7!#%%j"
- )
- ) else (
- if "!#%%l!"=="" (
- set "#%%l=未备份#已安装#_#%%j==%%k"
- ) else (
- set "#%%i=已备份#已安装!#%%l:~7!#%%j==%%k"
- )
- )
- )
- REM 过滤
- echo 已备份#未安装:
- echo.
- for /f "tokens=1-3* delims=#" %%i in ('set # ^| findstr "已备份#未安装"') do (
- set "pkgName=%%i"
- echo 包名: !pkgName:~0,-4!
- echo 文件: .\bak\%%k
- echo.
- )
- echo -----------------------------------------------------
- echo 未备份#已安装:
- echo.
- for /f "tokens=1-3* delims=#" %%i in ('set # ^| findstr "未备份#已安装"') do (
- set "pkgName=%%i"
- echo 包名: !pkgName:~0,-4!
- echo 路径: %%l
- echo.
- )
- echo -----------------------------------------------------
- pause&exit
复制代码
|