Assuming that findstr.exe
resides in %SystemRoot%System32
of your PE base OS, and the current working directory under which this script is running, holds your target .gho
files, here's an example template you can use:
@Echo Off
SetLocal EnableExtensions DisableDelayedExpansion
Set "ext=.gho"
For /F "Delims==" %%G In ('"(Set #) 2> NUL"') Do Set "%%G="
For /F "Tokens=1* Delims=:" %%G In ('Dir /B /A:-D "*%ext%" 2^> NUL ^| ^
%SystemRoot%System32findstr.exe /E /I /L /N "%ext%"'
) Do Set "#%%G=%%H" & Echo( %%G. %%H
If Not Defined #1 (Echo No file matches, press a key to exit.
Pause 1> NUL & GoTo :EOF)
:Opt
Set "opt="
Echo(
Set /P "opt=Enter the number for your chosen file>"
Set "opt=%opt:"=%"
Set # | %SystemRoot%System32findstr.exe /B /L "#%opt%=" 1> NUL || GoTo Opt
SetLocal EnableDelayedExpansion
For %%G In ("!#%opt%!") Do EndLocal & Set "opt=%%G"
Echo(
Echo( You Selected %opt%
Pause
As this is a template the extension on line 3 is replaceable with any other, as needed. Your own code would be written from line 18, (replacing the three example lines I included just to show you the result, now assigned to %opt%
. Nothing else between those two lines should be modified.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…