So that's a part of my script that lists files in a folder and displays them so I can select one and change its extension. It works as expected but I would like to add colours based on file extensions. For exemple .dll files show in green and .bak files show in red.
In the current state it shows the list in red no matter the extensions.
Code: Select all
@echo off
:menu4
cls
echo.
color 0a
setlocal enabledelayedexpansion
set Index=1
for %%i in (Mods\*) do (
set "SubFiles[!Index!]=%%i"
set /a Index+=1
)
set /a UBound=Index-1
for /l %%i in (1,1,%UBound%) do (
echo %%i. [91m!SubFiles[%%i]![92m rem Using Ansi escape color codes
)
:choiceloop
echo.
set /p Choice= Enter a number to change file extension :
if "%Choice%"=="" goto choiceloop
if %Choice% LSS 1 goto choiceloop
if "%Choice%"=="f" goto main
set SubFiles=!SubFiles[%Choice%]!
ren !SubFiles[%Choice%]! "*.dll"
ren !SubFiles[%Choice%]! "*.bak"
goto menu4