批处理之家's Archiver

youxi01 发表于 2008-1-18 18:36

CMD批处理获取文件的ASCII码

来源:dos联盟   作者:lxmxm
[code]
::Code by lxmxn @ bbs.cn-dos.net
:::::::::: GetASCII.Bat ::::::::::::
::Date 22:50 2007-1-9

@echo off&mode con cols=80
: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[/code]

页: [1]

Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.