批处理脚本多选菜单 [英] Batch script multiple choice menu

查看:74
本文介绍了批处理脚本多选菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个多媒体文件查看软件,可以在批处理脚本中调用该软件,以使用/LOADFILES参数加载文件.此参数接受多个用分号;"分隔的文件.

I have multimedia file viewing software that I call in a batch script to load files using an /LOADFILES argument. This argument accepts multiple files separated by semicolons ";".

我想要的是一个菜单,我可以从中选择要打开的文件.

What I would like is a menu from which I can select the files I want to open.

例如:

  1. Sample_01
  2. Sample_02
  3. Sample_03
  4. Sample_04
  5. Sample_05
  6. 全部

您有什么选择?

我们选择的内容最终存储在一个变量中,该变量由/LOADFILES参数解释.

And what we have selected ends up stored in a variable which is interpreted by the /LOADFILES argument.

目前,我的脚本能够一个接一个地打开所有现有示例:

For now, my script is able to open all the existing samples one after the other :

@echo off
for /f "delims=" %%I in ('dir /a:d-h /b "%SystemDrive%\software\sample\*"') do (
"%SystemDrive%\software\Viewer.exe" /LOADFILES="%%I"
)
pause
exit

但是我希望它只能读取从菜单中选择的样本,这些样本是在该程序的单独实例中的.

But I would like it to be able to read only the samples that I have selected from a menu, in separate instances of the program.

我不知道如何实现这一目标.

I have no specific idea of about how to achieve this.

任何帮助都会极大地帮助我改善脚本.

Any help would greatly help me improve my script.

谢谢.

推荐答案

下面是一个(非常基本的)脚本,向您展示了基本概念:

Here is a (very basic) script to show you the basic concept:

@echo off 
setlocal 
set "loadfiles="
:AddSamples
cls
echo current loadfiles: %loadfiles:~1%
echo add sample number
echo 1 - Sample_01
echo 2 - Sample_02
echo 3 - Sample_03
echo 4 - Sample_04
echo 5 - Sample_05
echo A - All and Go
echo G - Done and Go
choice /c 12345AG /m "What is your choice? "
if %errorlevel% == 1 set "loadfiles=%loadfiles%;Sample_01.mp3
if %errorlevel% == 2 set "loadfiles=%loadfiles%;Sample_02.mp3
if %errorlevel% == 3 set "loadfiles=%loadfiles%;Sample_03.mp3
if %errorlevel% == 4 set "loadfiles=%loadfiles%;Sample_04.mp3
if %errorlevel% == 5 set "loadfiles=%loadfiles%;Sample_05.mp3
if %errorlevel% == 6 set "loadfiles=;Sample_01.mp3;Sample_02.mp3;Sample_03.mp3;Sample_04.mp3;Sample_05.mp3" & goto :continue
if %errorlevel% == 7 goto :continue
goto :AddSamples
:Continue
set "loadfiles=%loadfiles:~1%"
"%SystemDrive%\software\Viewer.exe" /LOADFILES=%loadfiles%

这篇关于批处理脚本多选菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆