本帖最后由 dos-a 于 2023-4-9 15:25 编辑
如:
[1] 系统版本: 鸿蒙 2.0.0 model: VRD-W10 序列号: RCJ6R20A22000022
[2] 系统版本: andorid 12 model: 22021211RC 序列号: ad8670af
[3] 系统版本: 鸿蒙 2.0.022 model: VRD-W10 序列号: RCJ6R20A22000022
[4] 系统版本: andorid 12000 model: 22021211RC 序列号: ad8670af
[5] 系统版本: 鸿蒙 2.0.0.33 model: VRD-W10 序列号: RCJ6R20A22000022
[6] 系统版本: andorid 12 model: 22021211RC 序列号: ad8670af
这种打印后会因为使用得tab导致与上行显示结果不一致
如果我想让他们每列 左对齐我该怎么办?
如下是原bat:- :a
- cls
- @echo off
- setlocal enabledelayedexpansion
-
- rem 输出所有设备标识
- echo ╔═ ═╗
- echo 已连接设备
- echo ╔════════════════════════════════ ╚═ ═╝ ═════════════════════════════╗
- echo,
- set "cnt=0"
- for /f "skip=1 tokens=1 delims= " %%a in ('adb devices') do (
- REM 获取设备model号
- for /f "delims=" %%r in ('adb -s %%a shell getprop ro.product.model') do (
- for /f "delims=" %%x in ("%%r") do (
- set "f=%%x"
- )
- )
- set "cv="
- for /f "delims=" %%c in ('adb -s %%a shell getprop hw_sc.build.platform.version') do (
- for /f "delims=" %%x in ("%%c") do (
- set "cv=%%x"
- )
- )
- if "!cv!"=="" (
- REM 安卓
- for /f "delims=" %%s in ('adb -s %%a shell getprop ro.build.version.release') do (
- for /f "delims=" %%x in ("%%s") do (
- set "sv=%%x"
- )
- )
- set "version=!sv!"
- set "system=andorid"
- ) else (
- REM 鸿蒙
- set "version=!cv!"
- set "system=HarmonyOS"
- )
- set /a cnt+=1
- echo [!cnt!] 系统版本: !system! !version! model: !f! 序列号: %%a
- echo,
- )
- echo ╚══════════════════════════════════════════════════════════════════════════════════╝
- echo.
- pause
- goto a
复制代码 运行结果:
╔═ ═╗
已连接设备
╔════════════════════════════════ ╚═ ═╝ ═════════════════════════════╗
[1] 系统版本: 鸿蒙 2.0.0 model: VRD-W10 序列号: RCJ6R20A22000022
[2] 系统版本: andorid 12 model: 22021211RC 序列号: ad8670af
╚══════════════════════════════════════════════════════════════════════════════════╝
请按任意键继续. . .
这个是Batcher大佬在他的:
http://www.bathome.net/viewthread.php?tid=3774&from=favorites
中提到得左对齐思路
这部分是我修改后得但是结果不太行- @echo off
- :aap
- setlocal enabledelayedexpansion
- rem 输出所有设备标识
- echo ╔═ ═╗
- echo 已连接设备
- echo ╔════════════════════════════════ ╚═ ═╝ ═════════════════════════════╗
- echo,
- set "cnt=0"
- for /f "skip=1 tokens=1 delims= " %%a in ('adb devices') do (
- REM 获取设备model号
- for /f "delims=" %%r in ('adb -s %%a shell getprop ro.product.model') do (
- for /f "delims=" %%x in ("%%r") do (
- set "f=%%x"
- )
- )
- set "cv="
- for /f "delims=" %%c in ('adb -s %%a shell getprop hw_sc.build.platform.version') do (
- for /f "delims=" %%x in ("%%c") do (
- set "cv=%%x"
- )
- )
- if "!cv!"=="" (
- REM 安卓
- for /f "delims=" %%s in ('adb -s %%a shell getprop ro.build.version.release') do (
- for /f "delims=" %%x in ("%%s") do (
- set "sv=%%x"
- )
- )
- set "version=!sv!"
- set "system=andorid"
- ) else (
- REM 鸿蒙
- set "version=!cv!"
- set "system=HarmonyOS"
- )
- set /a cnt+=1
- set "ct= [!cnt!] "
- set "xb=系统版本:!system!!version!"
- set "md=model:!f!"
- set "xl=序列号:%%a"
- for /f "delims=" %%s in ("!ct! !xb! !md! !xl!") do (
- set /a n+=1&set /p=^%%s <nul
- if !n!==4 set n=0&echo .
- )
- ::echo [!cnt!] 系统版本: !system! !version! model: !f! 序列号: %%a
- echo,
- )
- echo ╚══════════════════════════════════════════════════════════════════════════════════╝
- echo.
-
- pause
- goto aap
复制代码 修改后得代码结果图如下:
╔═ ═╗
已连接设备
╔════════════════════════════════ ╚═ ═╝ ═════════════════════════════╗
[1] 系统版本:HarmonyOS2.0.0 model:VRD-W10 序列号:RCJ6R20A22000022
[2] 系统版本:andorid12 model:22021211RC 序列号:ad8670af
╚══════════════════════════════════════════════════════════════════════════════════╝
请按任意键继续. . .
求大佬助力!!!
我这边不知道为啥上传图片失败,暂时就不上图了 |