My batch code (Specifically designed to simply change the color) fails because the replace code fails. The text it is supposed to replace comes out like it entered.
echo Colors:
echo Black, blue, green, red, purple, yellow, white, gray, light blue, light green, light aqua, light red, light purple, light yellow, and bright white.
set /p COLOR=What color for the background?
set DASH=%COLOR: =-%
set COLORSETBACK=%DASH:black=0%
set COLORSETBACK=%DASH:blue=1%
set COLORSETBACK=%DASH:green=2%
set COLORSETBACK=%DASH:aqua=3%
set COLORSETBACK=%DASH:red=4%
set COLORSETBACK=%DASH:purple=5%
set COLORSETBACK=%DASH:yellow=6%
set COLORSETBACK=%DASH:white=7%
set COLORSETBACK=%DASH:gray=8%
set COLORSETBACK=%DASH:grey=8%
set COLORSETBACK=%DASH:light-blue=9%
set COLORSETBACK=%DASH:light-green=A%
set COLORSETBACK=%DASH:light-aqua=B%
set COLORSETBACK=%DASH:light-red=C%
set COLORSETBACK=%DASH:light-purple=D%
set COLORSETBACK=%DASH:light-yellow=E%
set COLORSETBACK=%DASH:bright-white=F%
cls
echo Colors:
echo Black, blue, green, red, purple, yellow, white, gray, light blue, light green, light aqua, light red, light purple, light yellow, and bright white.
set /p COLOR=What color for the text?
set DASH=%COLOR: =-%
set COLORSETTEXT=%DASH:black=0%
set COLORSETTEXT=%DASH:blue=1%
set COLORSETTEXT=%DASH:green=2%
set COLORSETTEXT=%DASH:aqua=3%
set COLORSETTEXT=%DASH:red=4%
set COLORSETTEXT=%DASH:purple=5%
set COLORSETTEXT=%DASH:yellow=6%
set COLORSETBACK=%DASH:white=7%
set COLORSETTEXT=%DASH:gray=8%
set COLORSETTEXT=%DASH:grey=8%
set COLORSETTEXT=%DASH:light-blue=9%
set COLORSETBACK=%DASH:light-green=A%
set COLORSETTEXT=%DASH:light-aqua=B%
set COLORSETTEXT=%DASH:light-red=C%
set COLORSETTEXT=%DASH:light-purple=D%
set COLORSETTEXT=%DASH:light-yellow=E%
set COLORSETTEXT=%DASH:bright-white=F%
color %COLORSETBACK%%COLORSETTEXT%
The set DASH=%COLOR: =-% is to change "light red" to light-red" and it works. However when I get to the set COLORSETTEXT=%DASH:black=0% the code fails to replace black with 0. I have tried different questions on different parts of the internet with no luck. If I were to type in red for the background and black for the text, the output would be "redblack" and I need it to be "40"