批处理将列出文件夹中的文件,询问我选择哪一个,当我选择它时将打开它
Batch will list files in a folder, ask me which one and when i choose it will open it
我看的所有脚本都是一样的,它们列出文件夹中的文件并要求我选择。当我按下例如“3”时,什么也没有发生。我想批量列出一个文件夹中的文件,然后让我选择一个,最重要的部分:打开我选择的内容
@echo off
setlocal enabledelayedexpansion
set count=0
set "choice_options="
for /F "delims=" %%A in ('dir /a:-d /b C:\image\Aselsan\') do (
REM Increment %count% here so that it doesn't get incremented later
set /a count+=1
REM Add the file name to the options array
set "options[!count!]=%%A"
REM Add the new option to the list of existing options
set choice_options=!choice_options!!count!
)
for /L %%A in (1,1,!count!) do echo [%%A]. !options[%%A]!
choice /c:!choice_options! /n /m "Enter a file to load: "
cmd /k
请帮我打开那个文本文件,我卡住了。谢谢你的帮助
你可以添加一行:
start C:\image\Aselsan\!options[%ERRORLEVEL%]!
完整:
@echo off
setlocal enabledelayedexpansion
set count=0
set "choice_options="
for /F "delims=" %%A in ('dir /a:-d /b "C:\image\Aselsan\"') do (
REM Increment %count% here so that it doesn't get incremented later
set /a count+=1
REM Add the file name to the options array
set "options[!count!]=%%A"
REM Add the new option to the list of existing options
set choice_options=!choice_options!!count!
)
for /L %%A in (1,1,!count!) do (
echo [%%A]. !options[%%A]!
echo %%A
)
choice /c:!choice_options! /m "Enter a file to load: "
start C:\image\Aselsan\!options[%ERRORLEVEL%]!
cmd /k
我看的所有脚本都是一样的,它们列出文件夹中的文件并要求我选择。当我按下例如“3”时,什么也没有发生。我想批量列出一个文件夹中的文件,然后让我选择一个,最重要的部分:打开我选择的内容
@echo off
setlocal enabledelayedexpansion
set count=0
set "choice_options="
for /F "delims=" %%A in ('dir /a:-d /b C:\image\Aselsan\') do (
REM Increment %count% here so that it doesn't get incremented later
set /a count+=1
REM Add the file name to the options array
set "options[!count!]=%%A"
REM Add the new option to the list of existing options
set choice_options=!choice_options!!count!
)
for /L %%A in (1,1,!count!) do echo [%%A]. !options[%%A]!
choice /c:!choice_options! /n /m "Enter a file to load: "
cmd /k
请帮我打开那个文本文件,我卡住了。谢谢你的帮助
你可以添加一行:
start C:\image\Aselsan\!options[%ERRORLEVEL%]!
完整:
@echo off
setlocal enabledelayedexpansion
set count=0
set "choice_options="
for /F "delims=" %%A in ('dir /a:-d /b "C:\image\Aselsan\"') do (
REM Increment %count% here so that it doesn't get incremented later
set /a count+=1
REM Add the file name to the options array
set "options[!count!]=%%A"
REM Add the new option to the list of existing options
set choice_options=!choice_options!!count!
)
for /L %%A in (1,1,!count!) do (
echo [%%A]. !options[%%A]!
echo %%A
)
choice /c:!choice_options! /m "Enter a file to load: "
start C:\image\Aselsan\!options[%ERRORLEVEL%]!
cmd /k