chcp 65001
:::模块adb devices id
:pull
setlocal enabledelayedexpansion
for /f "skip=1 tokens=1" %%i in ('adb devices') do (
d:
md D:\Sdk_logs
md D:\Sdk_logs\%%i
cd D:\Sdk_logs\%%i
set dmy=%date:~3,4%%date:~8,2%%date:~11,2%
set hm=%time:~0,2%_%time:~3,2%_%time:~6,2%
adb -s %%i pull /usrdata/logs D:\Sdk_logs\%%i\logs_!dmy!_!hm!
)
timeout /t 36000
:::timeout /t 10
goto pull
pause
在for循环中是使用变量要开启环境变量延迟命令
setlocal enabledelayedexpansion
并把原来的%更换为!来引用变量
skip=1 此参数为跳过命令返回的前几行,1为跳过第一行
tokens=1 此参数为选取一行中的第几项(默认空格为分隔符)