New
#1
Colour code TEXT in a batch file!
Good afternoon,
I have written a batch file which works great!
However, I would like to colour several pieces of text within the batch file.
I have spent a LONG time researching this on Google and I am almost there.
This is what I have at the top of the code...
This is what I have as an example that I want to colour red [which it does]...Code:@echo off SETLOCAL EnableDelayedExpansion for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do ( set "DEL=%%a" )
This is what I have as the :ColorText code...Code:call :ColorText 0c " IMPORTANT - Numbers 2 blah blah." call :ColorText 0c " If you blah blah!" & set /p ".= " < nul echo.
The questions I have are...Code::ColorText rem echo off <nul set /p ".=%DEL%" > "%~2" findstr /v /a:%1 /R "^$" "%~2" nul del "%~2" > nul 2>&1 GOTO :EOF
[1] If I put a colon [:] after Important, is doesn't work, hence the dash [-]?
[2] Why will it not show the exclamation [!] at the end of the line although it is there?
[3] Why will it not show the full stop [.] at the end of the line although it is there?
[4] Is there a way to split the call :ColorText 0c " IMPORTANT - Numbers 2 blah blah." over two lines so it makes it esaier to read and also lines up in the script with the code below it. I tried several options, all to no avail!
[5] As you see from the middle piece of code, the Numbers 2 and If you are not lined up, but they are in the consol!
[6] Why doesn't it put a blank row after even though there is a echo. after the text to be coloured, but it does if I use & set /p ".= " < nul end & echo..
[7] It will also not accept forward slash [/]!
Thanks in advance.
Last edited by Paul Black; 27 Apr 2019 at 10:28.