如何在批处理文件中创建两列?

时间:2012-11-30 23:05:41

标签: command-line batch-file

我有1列,它要求用户输入或他们想要观看的流,但是一列不足以支持所有频道。

以下是它的外观截图 enter image description here


如何在第一列显示1到10,在第二列显示11到20。

这是我的代码..不包括流链接。

<br><br>
@echo off
rem mode con:cols=60 lines=16
mode con:cols=50 lines=40

:VRH
title HD Indian Channels By  
cls
COLOR 0E
echo       Install VLC Player & OctoShape: VLC Player
echo        Select Channel Number You Want To Watch!
echo.
echo             (1)  = Sahara Samay     +1
echo             (2)  = India TV         +2
echo             (3)  = NDTV Hindi       +3
echo             (4)  = Sahara Mumbai    +4
echo             (5)  = Times Now        +5
echo             (6)  = Saharah AP       +6
echo             (7)  = News X           +7
echo             (8)  = Punjabi          +8
echo             (9)  = Al Jazeera Sport +9
echo             (10) = Al Jazeera Sport +10
echo             (11) = Aaj Tak          +11
echo             (12) = Headlines Today  +12
echo             (13) = UTV Bindaas      +13
echo             (14) = HumTV            +14
echo             (15) = M Tunes          +15
echo             (16) = HumTV            +16
echo             (17) = Masalaa TV       +17
echo             (18) = Zee Cinema       +18
echo             (19) = B4u Music        +19
echo             (20) = Zing             +20
echo             (21) = Zee TV           +21
echo             (22) = ETV US           +22
echo             (23) = Zoom TV          +23
echo             (24) = Al Jazeera Eng   +24
echo             (25) = 9xm Jalwa        +25
echo             (26) = Headlines Today  +26
echo             (27) = UTV US Movies    +27
echo             (28) = UTV Bindaas      +28
echo             (29) = UTV Bindaas      +29
echo             (30) = UTV Bindaas      +30
echo.
echo                     (O)  = Izlaz

if exist C:\Progra~1\VideoLAN\VLC (set "vlc=C:\Progra~1\VideoLAN\VLC\vlc") 
if exist C:\Progra~2\VideoLAN\VLC (set "vlc=C:\Progra~2\VideoLAN\VLC\vlc")
if exist C:\Program Files\VideoLAN\VLC (set "C:\Program Files\VideoLAN\VLC\vlc")
if exist D:\Program Files\VideoLAN\VLC (set "D:\Program Files\VideoLAN\VLC\vlc")
if exist C:\Program Files (x86)\VideoLAN\VLC (set "C:\Program Files (x86)\VideoLAN\VLC\vlc")
if exist C:\Program Files(x86)\VideoLAN\VLC (set "C:\Program Files(x86)\VideoLAN\VLC\vlc")
if exist C:\Program Files (x64)\VideoLAN\VLC (set "C:\Program Files (x64)\VideoLAN\VLC\vlc")
if exist C:\Program Files(x64)\VideoLAN\VLC (set "C:\Program Files(x64)\VideoLAN\VLC\vlc")

set /p "Choice=>"

IF "%Choice%"=="0" GOTO 0
IF "%Choice%"=="1" GOTO 1
IF "%Choice%"=="2" GOTO 2
IF "%Choice%"=="3" GOTO 3
IF "%Choice%"=="4" GOTO 4
IF "%Choice%"=="5" GOTO 5
IF "%Choice%"=="6" GOTO 6
IF "%Choice%"=="7" GOTO 7
IF "%Choice%"=="8" GOTO 8
IF "%Choice%"=="9" GOTO 9
IF "%Choice%"=="10" GOTO 10
IF "%Choice%"=="11" GOTO 11
IF "%Choice%"=="12" GOTO 12
IF "%Choice%"=="13" GOTO 13
IF "%Choice%"=="14" GOTO 14
IF "%Choice%"=="15" GOTO 15
IF "%Choice%"=="16" GOTO 16
IF "%Choice%"=="17" GOTO 17
IF "%Choice%"=="18" GOTO 18
IF "%Choice%"=="19" GOTO 19
IF "%Choice%"=="20" GOTO 20
IF "%Choice%"=="21" GOTO 21
IF "%Choice%"=="22" GOTO 22
IF "%Choice%"=="23" GOTO 23
IF "%Choice%"=="24" GOTO 24
IF "%Choice%"=="25" GOTO 25
IF "%Choice%"=="26" GOTO 26
IF "%Choice%"=="27" GOTO 27
IF "%Choice%"=="28" GOTO 28
IF "%Choice%"=="29" GOTO 29
IF "%Choice%"=="30" GOTO 30


echo.
echo Odaberi od 1 do 10...
echo.
ping localhost -n 3 >nul
goto VRH

如果选择不包括所有案例,我认为不需要..

:0
cls
echo Al Jazeera Sports in VLC by D3n1s
ping localhost -n 3 >nul
exit /b 

3 个答案:

答案 0 :(得分:1)

使用标签按钮。还要检查MORE和LESS utils。

答案 1 :(得分:1)

假设您正尝试分页(显示多行,然后在用户按下某个键时暂停,然后显示下一组等等),那么您只需在每个想要的位置插入暂停等待。然后系统将暂停并要求用户按任意键继续,当用户这样做时,它将继续。

例如:

echo             (1)  = Sahara Samay     +1
echo             (2)  = India TV         +2
echo             (3)  = NDTV Hindi       +3
echo             (4)  = Sahara Mumbai    +4
echo             (5)  = Times Now        +5
echo             (6)  = Saharah AP       +6
echo             (7)  = News X           +7
echo             (8)  = Punjabi          +8
echo             (9)  = Al Jazeera Sport +9
echo             (10) = Al Jazeera Sport +10
pause
echo             (11) = Aaj Tak          +11
echo             (12) = Headlines Today  +12
echo             (13) = UTV Bindaas      +13
echo             (14) = HumTV            +14
echo             (15) = M Tunes          +15
echo             (16) = HumTV            +16
echo             (17) = Masalaa TV       +17
echo             (18) = Zee Cinema       +18
echo             (19) = B4u Music        +19
echo             (20) = Zing             +20
pause

等等

答案 2 :(得分:1)

如果要在屏幕的同一行显示两列,则必须在echo命令中组合所需的输出(两列)。要做到这一点,你必须有办法分开两列;通常的方法是使用TAB字符。要在Win-XP中获取TAB字符,您可以使用以下代码:

for /F "skip=4 delims=pR tokens=1,2" %%a in (
       'reg query hkcu\environment /v temp' ) do set TAB=%%b

要以您想要的方式显示输出(“在第一列中显示1到10,在第二列中显示11到20”),您可以使用以下代码:

@echo off
setlocal EnableDelayedExpansion
rem Get TAB character
for /F "skip=4 delims=pR tokens=1,2" %%a in (
       'reg query hkcu\environment /v temp' ) do set TAB=%%b

rem Show the desired output
echo             (1)  = Sahara Samay     +1!TAB!(11) = Aaj Tak          +11
echo             (2)  = India TV         +2!TAB!(12) = Headlines Today  +12
echo             (3)  = NDTV Hindi       +3!TAB!(13) = UTV Bindaas      +13
echo             (4)  = Sahara Mumbai    +4!TAB!(14) = HumTV            +14
echo             (5)  = Times Now        +5!TAB!(15) = M Tunes          +15
echo             (6)  = Saharah AP       +6!TAB!(16) = HumTV            +16
echo             (7)  = News X           +7!TAB!(17) = Masalaa TV       +17
echo             (8)  = Punjabi          +8!TAB!(18) = Zee Cinema       +18
echo             (9)  = Al Jazeera Sport +9!TAB!(19) = B4u Music        +19
echo             (10) = Al Jazeera Sport +10!TAB!(20) = Zing             +20

但是,我强烈建议您在数组中管理此类数据。有关详细信息,请参阅this link

您可以查看并高级批处理程序,在this post

显示两列数据

我希望它有所帮助...

安东尼奥