-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSELECT_DIRS.BAT
64 lines (52 loc) · 1.17 KB
/
SELECT_DIRS.BAT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
@echo off
setlocal ENABLEDELAYEDEXPANSION
set numberOfOptions=0
for /D %%f in (*.*) do (
set options[!numberOfOptions!]=%%f
set m[!numberOfOptions!]=
set /a numberOfOptions=!numberOfOptions!+1
)
set selected=0
set /a highestOption=%numberOfOptions%-1
:menu
cls
echo Make your choice:
echo.
FOR /L %%i IN (0,1,%highestOption%) DO (
if "%selected%"=="%%i" (
echo ^> [!m[%%i]!] !options[%%i]!
) else echo [!m[%%i]!] !options[%%i]!
)
echo.
echo Use WS to navigate up and down
echo Press Q to select an option
echo Press E when finished
choice /N /C:WSQE
if errorlevel 255 goto menu
if errorlevel 4 goto finish
if errorlevel 3 goto wahl
if errorlevel 2 goto runter
if errorlevel 1 goto hoch
if errorlevel 0 goto menu
:hoch
set /a "selected-=1"
if %selected% LSS 0 set selected=0
goto menu
:runter
set /a "selected+=1"
if %selected% GTR %highestOption% set selected=%highestOption%
goto menu
:wahl
if "!m[%selected%]!"==" " (
set m[%selected%]=X
goto menu
)
if "!m[%selected%]!"=="X" set m[%selected%]=
goto menu
:finish
set result=
FOR /L %%i IN (0,1,%highestOption%) DO (
if "!m[%%i]!"=="X" set result=!result! !options[%%i]!
)
endlocal & set ret=%result%
set "%~1=%ret%"