本帖最后由 a20150604 于 2019-8-30 14:46 编辑
屏幕输出示例:- Active code page: 65001
- 1 file(s) copied.
- 当前 applicationId 是: "com.daoliu.yo0507"
- 请输入新的 applicationId:a.b.c..
- 参数格式不正确, 请再次输入.
- 请输入新的 applicationId:a.b.cd.3fg
- 当前 versionCode 是: 470
- 请输入新的 versionCode:853e
- 参数格式不正确, 请再次输入.
- 请输入新的 versionCode:654
- 当前 versionName 是: "0.6.0"
- 请输入新的 versionName:s.35.2wg
- 参数格式不正确, 请再次输入.
- 请输入新的 versionName:2.3.56.7
- The syntax of the command is incorrect.
- The syntax of the command is incorrect.
- DONE
- Press any key to continue . . .
复制代码
- @echo off & setlocal enabledelayedexpansion & chcp 65001
-
- set "QDH=[a-zA-Z][0-9a-zA-Z]*"
- set "QDN=\.[0-9a-zA-Z][0-9a-zA-Z]*"
- set "quote_domain=^\"%QDH%\"$ ^\"%QDH%%QDN%\"$ ^\"%QDH%%QDN%%QDN%\"$ ^\"%QDH%%QDN%%QDN%%QDN%\"$"
- set "domain=%quote_domain:\"=%"
-
- set "QDDH=[0-9][0-9]*"
- set "QDDN=\.%QDDH%"
- set "quote_dot_digit=^\"%QDDH%\"$ ^\"%QDDH%%QDDN%\"$ ^\"%QDDH%%QDDN%%QDDN%\"$ ^\"%QDDH%%QDDN%%QDDN%%QDDN%\"$"
- set "dot_digit=%quote_dot_digit:\"=%"
-
- set "pure_digit=^%QDDH%$"
-
- call :wmic_get_timestamp YYYYMMDD_HHiiss
-
- copy /y build.txt build.BAK.%YYYYMMDD_HHiiss%.txt
- > build.txt cd.
- for /f "delims=" %%a in (build.BAK.%YYYYMMDD_HHiiss%.txt) do (
-
- REM 过滤出目标参数行
- echo;%%a|findstr /r /i "[^0-9a-zA-Z\.]applicationId [^0-9a-zA-Z\.]versionCode [^0-9a-zA-Z\.]versionName" >nul && (
-
- REM echo;&echo;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- REM echo;found target param line:&echo;
- for /f "tokens=1*" %%c in ("%%a") do (
-
- echo;当前 %%c 是: %%d
-
- for %%e in (quote_domain pure_digit quote_dot_digit) do (
- set "validate_str=!%%e!"
- set "types=%%e"
- if "!types:~0,6!"=="quote_" (
- set "types=!types! !types:~6!"
- )
- echo;%%d|findstr /r /i "!validate_str!" >nul && (
- call :input_param param_val %%c !types!
- )
- )
- >> build.txt echo;%%c !param_val!
- REM echo;++++++++++++++++ new set ++++++++++++++++
- REM echo;%%c !param_val!
- )
- ) || (
- >> build.txt echo;%%a
- REM echo;%%a
- )
- )
- echo;DONE
- pause
- exit
-
- :input_param var_param_val param_name validate_type no_quote_validate_type
- setlocal
-
- if "%~4" neq "" (
- set "no_quote_validate_type= !%~4!"
- )
-
- :input_param_loop
- set /p "param_val=请输入新的 %~2:"
-
- echo;%param_val%| findstr /r /i "!%~3!!no_quote_validate_type!" >nul && (
- (
- endlocal
- set "%~1=%param_val%"
- if "%~4" neq "" (
- for %%a in (%param_val%) do set "%~1="%%~a""
- )
- exit /b
- )
- ) || (
- echo;参数格式不正确, 请再次输入.
- goto :input_param_loop
- )
- exit /b
-
- :wmic_get_timestamp YYYYMMDD_HHiiss
- setlocal
- for /f %%x in ('wmic path win32_localtime get /format:list ^| findstr "="') do (
- for /f "tokens=1-2 delims==" %%a in ("%%x") do (set "_%%a=0000%%b")
- )
- (
- endlocal
- set "%~1=%_Year:~-4%%_Month:~-2%%_Day:~-2%_%_Hour:~-2%%_Minute:~-2%%_Second:~-2%"
- exit /b
- )
复制代码
|