hex2dec.bat
来自「高手lxmxn收集的批处理。包括了批处理教程和他写的几十个很经典的代码。」· Batch 代码 · 共 38 行
BAT
38 行
::cody by lxmxn @ cn-dos.net
::十六进制转到十进制
::Date 16:23 2007-1-12
@echo off&Setlocal EnableDelayedExpansion
:redo
set /p str=Please input a hex string:
if "%str%"=="" echo Invalid input,please input again.&pause&goto redo
cls&set a=0
:begin
if not "!str:~%a%,1!"=="" set /a a+=1&&goto begin
echo The string you inputed is →%str%←,it's length:→%a%←
if "%1"=="/z" goto zhuanhuan
echo;
set/p=The final result is:→<nul
for /l %%a in (0,2,%a%) do (
Setlocal EnableDelayedExpansion
if not "!str:~%%a,1!"=="" (
set /p result=%%!str:~%%a,2!<nul
)
Endlocal
)
echo ←
echo;
set /p choose=Change it to Hexadecimal? Please Enter Y or N to choose:^>
if /i not "%choose%"=="y" goto :eof
echo %str%|findstr "^[0-9a-fA-F]*$" >nul
if errorlevel 1 echo;&echo;The string isn't a hexadecimal number.Any key to Exit.&pause>nul&goto :eof
:zhuanhuan
echo;
(for /l %%a in (0,2,%a%) do (
Setlocal EnableDelayedExpansion
if not "!str:~%%a,1!"=="" (
set /a b=0x!str:~%%a,2!
set /p b= !b!<nul
)
Endlocal
))&echo;&echo;&set/p=Press any key to exit.<nul&pause>nul&goto :eof
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?