
CODE: [Copy to clipboard][ Last edited by namejm on 2007-5-29 at 11:28 PM ]@echo off
:: 思路:在系统临时目录下创建随机文件,把检测非法字符的任务交给操作系统来完成
:: Thanks to qzwqzw
:main
cls
set input=
set /p input= 请输入文件名:
call :check
pause
goto main
:check
set "str1=%input:"=%"
set "str2=%input:"= %"
if not "%str1%"=="%str2%" goto main
:loop
set rnd=%random%
if exist "%tmp%\%input%%rnd%" goto loop
cd.>"%tmp%\%input%%rnd%" 2>nul || goto main
del /q "%tmp%\%input%%rnd%"
echo "%input%" 是合法的文件名
goto :eof
| Quote: | |
|
| 欢迎光临 中国DOS联盟论坛 (http://cndos.fam.cx/forum/) | Powered by Discuz! 2.5 |