@ECHO OFF REM Copyright (c) 2018 by /u/AyrA_ch REM Example directory browser in batch file REM Enable Support for "!" expansion SETLOCAL ENABLEDELAYEDEXPANSION REM Starting point CD /D C:\ REM Lists all directories and files :LOOP CLS ECHO Content of "%CD%" REM Dirs ECHO. ECHO Directories: SET COUNT=0 ECHO !COUNT!: ^<..^> FOR /D %%I IN (*.*) DO ( SET /A COUNT=!COUNT!+1 SET DIR[!COUNT!]=%%I ECHO !COUNT!: %%I ) REM Files ECHO. ECHO Files: FOR %%I IN (*.*) DO ( SET /A COUNT=!COUNT!+1 SET FILE[!COUNT!]=%%I ECHO !COUNT!: %%I ) REM Make Selection ECHO. SET /P SEL=Select [Q, 0-%COUNT%]: REM Check for special selection IF /I "%SEL%"=="Q" GOTO END IF "%SEL%"=="0" GOTO UP REM Check if file IF NOT "!FILE[%SEL%]!"=="" GOTO EXEC REM Check if Dir IF NOT "!DIR[%SEL%]!"=="" GOTO LIST REM Neither GOTO CLEAR REM Directory up :UP CD .. GOTO CLEAR REM Execute selection (is file) :EXEC START /D "%CD%" !FILE[%SEL%]! REM use "CLEAR" to not exit this file GOTO END REM Navigate to selection :LIST CD "!DIR[%SEL%]!" GOTO CLEAR REM Clear set variables and show list :CLEAR FOR /L %%I IN (1,1,%COUNT%) DO ( SET FILE[%%I]= SET DIR[%%I]= ) GOTO LOOP REM Exit :END REM This automatically clear up ENDLOCAL
Comments
0 B
|👍
/👎