I am new to the world of programming and trying to make a small script where I can select a folder with a name that will chance and make this selected folder a subst drive.
The code that I already found on this site is pretty good, but it seems that i am missing a lot of knowledge to make this a working batch file.
The code that I have is:
@echo off
echo Select a folder. Terminate folder number with + to open it.
echo/
call :SelectFolder selectedFolder
echo/
echo Selected folder: %selectedFolder%
goto :EOF
:SelectFolder returnVar
setlocal EnableDelayedExpansion
:nextFolder
echo/
echo %cd%
set i=0
set folder[0]=..
echo 0- ..
for /D %%d in (*) do (
set /A i+=1
set folder[!i!]=%%d
echo !i!- %%d
)
:getOption
set option=0+
set openFolder=1
set /P "option=Enter the desired folder: "
if "%option:~-1%" equ "+" (
set option=%option:~0,-1%
) else (
set openFolder=
)
if %option% gtr %i% goto getOption
cd "!folder[%option%]!"
if defined openFolder goto nextFolder
endlocal & set %1=%cd%
:SubstK
subst K: %selectedFolder%
pause
The folders that I am trying to subst look something like this.
C:/system/microcode/brand1
C:/system/microcode/brand2
This is the first selection that I want to make. we have to different brands and i would like to choose between the two of these before it continues.
After choosing which brand I have, there is a list of folders which I would like to make a selection from and then subst the folder that I chose. I will be adding more folders to this "type" folders so in the future there will be a "type3" "type4" etc.
example.
C:\system\microcode\brand1
|--- type1
\--- type2
C:\system\microcode\brand2
|--- type1
\--- type2
I don't even know if this is possible with a simple batch file but better ask than be sorry.