
這個以16進制或10進制讀取的批處理有什么缺陷
找到一個能以16進制或10進制讀取的批處理但有BUG這個代碼16進制00就不能讀出10進制0也是一樣告訴我哪里不對?謝謝nclick="copycode($('code0'));">復制代碼
- @echo off
- :begin
- cls
- set/p file=請輸入要處理的文件(Q 鍵直接退出此腳本):
- if /i %file%==Q goto :eof
- if %file%== goto error
- set new=%random%
- for %%a in (%file%) do set size=%%~za
- if %size%==0 goto error
- cls&fsutil file createnew %new% %size% >nul
- echo=&&echo=文件內容所對應的ASCII碼的十六進制形式依次為:&echo==========================================================
- for /f skip=1 tokens=3 %%a in ('fc /B %new% %file%') do (
- set /p=%%a <nul
- )
- echo=&echo==========================================================&echo=&echo=&echo=文件內容所對應的ASCII碼的十進制形式依次為:&echo==========================================================
- setlocal EnableDelayedExpansion
- for /f skip=1 tokens=3 %%a in ('fc /B %new% %file%') do (
- set num=%%a
- set /a num=0x!num!
- set /p=!num! <nul
- )
- del %new%
- endlocal&echo;&echo==========================================================&echo;&pause
- exit /b 0
- :error
- cls&echo;&echo;
- echo “輸入錯誤” OR “文件大小為零”,請重新輸入……
- del %new% >nul 2>nul
- set file=
- set new=
- pause>nul&goto :begin

