|
本帖最后由 dos时代菜鸟 于 2022-9-7 09:00 编辑
用 for + set + if ,搞定。其实 逻辑很简单。
- @echo off
- setlocal ENABLEDELAYEDEXPANSION
- set str1="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- set strx=
- set /p str2=请输入一组excel单元格坐标,用逗号相隔,如(1a,2b,3c,4d...):
- for %%a in (!str2!) do (
- set str0=
- for /f "tokens=1 delims=1234567890" %%d in ("%%a") do (
- set str0=%%a
- set str0=!str0:%%d=!
- call :str3x "!str0!" "%%d"
- )
- )
- echo !strx!
- pause
- goto :eof
- :str3x
- set "str3=%~2"
- set x2=
- set x1=
- set L1=!str3:~0,1!
- set L2=!str3:~1,1!
- for /l %%f in (1,1,26) do (
- if /i "!L1!"=="!str1:~%%f,1!" set x1=%%f
- if /i "!L2!"=="!str1:~%%f,1!" set x2=%%f
- )
- if "!x2!"=="" (
- set x=!x1!
- ) else (
- set /a x=!x1!*26+!x2!
- )
- set strx=!strx! (%~1,!x!)
- exit /b
复制代码
|
|