1. 程式人生 > 實用技巧 >一些Bat指令碼

一些Bat指令碼

loop指令碼

@title z_loop
@echo off
rem ==================
set times=8
rem ==================
set num=1
set /a times+=1
:loop
if not %num% == %times% (
@echo on
rem ------------------begin------------------
rem write here that need to loop
    echo ------------------Loops: %num%------------------
    echo Hello
    
    timeout 1  >nul 2>nul
rem -------------------end-------------------
@echo off
    set /a num+=1
) else (
    goto loopend
)
goto loop
:loopend
echo Done.
@echo on
pause

adb拉Log

@title z_log
@echo off
rem Get SN
set SN="%1"
if "%1" == "" (
    adb wait-for-device
    for /f "delims=" %%i in ('adb shell getprop ro.serialno') do (set SN=%%i))
rem Get format Time
set s_lyear=%date:~0,4%
set s_year=%date:~2,2%
set s_month=%date:~5,2%
set s_day=%date:~8,2%
set s_hour=%time:~0,2%
set s_hour=%s_hour: =0%
set s_minute=%time:~3,2%
set s_second=%time:~6,2%
set s_time_full=%s_lyear%%s_month%%s_day%-%s_hour%%s_minute%%s_second%
set s_time=%s_month%%s_day%%s_hour%%s_minute%
rem Get dir_name
set dir_name=%SN%_%s_time%
mkdir %dir_name%
@echo on
adb -s %SN% pull /data/debug_service/ %dir_name%/debug_service