@echo off
:: ܣ
::
::  ӢģʾӢĿµݣ
:: ͬʱʾʿдڵġͬͷͬʣ
::      뺺ʾаúʻӢ
::
:: ʿļĸʽҪ
::
:: ļһݱΪգ߲ܳҪݵ
:: һбΪӢĴʻ
:: ķݽһ(ִĸ)ж
:: ֮¿о
:: ÿͺİ״̬µķֺźͿո
::     ݿͬһУҲڲͬ
:: ֮µľݾİ״̬µķֺźͿոõ
:: ÿʹÿзָ
::
::             code by JM 2006-10-1114    bbs.cn-dos.net

:input_var
title Ӣ
cls
set line=
set postil=
set postil_content=
set similar=
set input=
set /p input=Ҫѯ(Ҫ˳ֱӻس)
if "%input%"=="" exit

ren ============== ж ==============
cls
echo %input%|findstr /b "[a-zA-Z]">nul && goto letters || goto not-letters

ren ============== Ӣ뺺 ==============
:letters
title Ӣ-Ӣ뺺
:: ȡƥ䵥ʵĵһ¼Ȼٴ֮²ҵһγֵĵ
:: ֮ݾӢĵķ
for /f "tokens=1* delims=:" %%i in ('findstr /nirc:"^%input%" ʿ.txt') do (
    if /i "%%j"=="%input%" set line=%%i&goto word_finded
)
if "%line%"=="" goto no-item
:word_finded
echo _________________________________
echo Ҫҵĵʣ%input%
echo.
setlocal enabledelayedexpansion
for /f "skip=%line% delims=" %%i in (ʿ.txt) do (
    echo %%i|findstr "^[a-zA-Z]*$">nul &&(goto no-postil)||(
        echo     %%i&if not "%%i"=="" set postil=exist
        echo %%i|findstr /c:" ">nul &&(
            set postil_content=!postil_content!%%i
        )            
    )
)
:no-postil
if "%postil%"=="" (echo     %input% Ŀûκ & goto end)
echo _________________________________
echo Ƶĵʣ
echo.
for /f "tokens=1* delims=:" %%i in ('findstr /nr "%postil_content%" ʿ.txt') do (
    if not "%%j"=="" set /a line=%%i-2&& call :check_similar
)
if "%similar%"=="" echo     ޡ
echo _________________________________
echo ͷͬʻ㣺
echo.
set similar=
for /f "tokens=1* delims=:" %%i in ('findstr /nirc:"^%input%" ʿ.txt') do (
    echo %%j|findstr "^[a-zA-Z]*">nul && (
        if not "%%j"=="%input%" set similar=exist&echo     %%j
    )
)
if "%similar%"=="" echo     ޡ
:end
echo _________________________________
echo.
pause
goto input_var

:check_similar
:: Ҵк%postil_content%ӢĴʻ
for /f "skip=%line% delims=" %%i in (ʿ.txt) do (
    echo %%i|findstr "^[a-zA-Z]*$">nul &&(
        if not "%%i"=="%input%" (
            echo     %%i&set similar=exist&goto :eof
            ) else (goto :eof)
    )||(set /a line=%line%-1& goto check_similar)
)
goto :eof

ren ============== Ӣ ==============
:not-letters
title Ӣ-Ӣ
:: ȡúʻĵһ¼Ȼٲλڸ֮ϵĴĸ
:: һҵĴĸоҪҵӢĵ
:: ظϹ̾ͿԲҵаʻӢĴʻ
echo _________________________________
echo.
echo %input%:
echo.
for /f "tokens=1* delims=:" %%i in ('findstr /nrc:"%input% " ʿ.txt') do (
    if not "%%j"=="" set /a line=%%i-2&& call :check_word
)
if "%postil%"=="" goto no-item
echo _________________________________
echo.
pause
goto input_var

:check_word
:: Ҵк%input%ӢĴʻ
set postil=exist
for /f "skip=%line% delims=" %%i in (ʿ.txt) do (
    echo %%i|findstr "^[a-zA-Z]*$">nul &&(echo     %%i&&goto :eof)||(
        set /a line=%line%-1&& goto check_word
    )
)
goto :eof

ren ============== ʾ ==============
:no-item
cls
echo _________________________________
echo.
echo %input%:
echo ûҵĿ!
echo _________________________________
echo.
pause
goto input_var