Introduction: Different Colours in Batch Files
Everyone, with the help of g-one, I have created a function that you can install into your windows/system32 folder to get more than one colour in batch files.
Copy and paste the following code and save it as ncol.bat (this is very important that you save it exactly like that).
setlocal
if "%~1"=="/?" (
echo.
echo ncol ["Text"] [Colour]
echo.
echo "Text" - The text you want displayed in another colour.
echo Remember that spaces cannot be added if you don't put the text in
echo quotation marks (""^).
echo.
echo Colour - The hexadecimal colour code that you want the text to be changed into.
echo For more information of colour codes, see "color /?"
echo.
exit /b
)
for /f "delims=#" %%i in ('"prompt #$H# &for %%b in (1) do rem"') do set "bs=%%i"
findstr /p /a:%2 . "*.@"
endlocal
del "*.@"
@echo on
@exit /b
Once that is done, head over to your windows system32 folder and save it in there (C:\Windows\System32)
Read on for instructions...
Step 1: Instructions
Firstly, type it in as you would any command "ncol"
The first parameter is the text you want converted.
The second parameter is the colour (must be correspondent to the colour command).
Example:
ncol "Hello" 10
Would output:
Hello
Just try it!
Note: If you have spaces, you must use quotation marks ("").
P.S: type in "ncol /?" for more help.
Unfortunately, special characters cannot be converted yet... (~!@#$%^&*()_+=-/,.<>":;'[]\{}|`)
And there is a little glitch with it, but other than that... It's good to go!
--EDIT--
To add more colors onto one line, use the && operator. E.g: ncol "Hello " 12 && ncol "there" 23
would output "Hello " in one color, and "there" in another.
26 Comments
1 year ago
Does the file have to be named "ncol.bat" ?
6 years ago
umm... when i do that i get
'"Hello.@"' is not recognized as an internal or external command,
operable program or batch file.
FINDSTR: Cannot open *.@
Could Not Find C:\Users\MyName\*.@
8 years ago on Introduction
No its fine, i found a different program that does the same thing but works. I still like ur idea though.
Reply 8 years ago on Introduction
Im making a movement simulator game in batch (Kind of like Terraria) And for every block is a character (or piece of text). I really want to save myself from writing over 300 variables. So is there a way to have arrays in batch?
Reply 7 years ago
https://www.instructables.com/id/Multiple-colors-in...
That is a working version and where can I get that it sounds cool.
7 years ago
Everyone I made a version that works view it here
https://www.instructables.com/id/Multiple-colors-in-cmd/
7 years ago
Hey Pickle! just wanted to say thanks because your instructables have really helped me with getting into batch but just a question. Why don't you create any more instructables? it would be really nice if you had more :)
Reply 7 years ago
he does have more here
https://www.instructables.com/member/Prof.+Pickle/
And here is a full screen matrix
https://www.instructables.com/id/Full-screen-batch-...
:)
Reply 7 years ago
but he doesn't post anymore does he? his last post was maybe 1 or 2 years ago. He used to be the person who fixed all my codes that didn't work and now i have piles of not working code
7 years ago
Thanks, I've been trying to find a code for this. I'm thinking of using it in my Trivia.
7 years ago on Introduction
You should add here the *.@ file that you have in your system32 because we need that and thats why it isnt working
8 years ago on Introduction
It says the following when i type "ncol" in cmd.exe
'".@"' is not recognized as an internal or external command,
operable program or batch file.
FINDSTR: Argument missing after /a
Could not find C:\Users\****** ********\*.@
Reply 8 years ago on Introduction
NCOL is a function, meaning that you need to put in the name (ncol) and then the arguments. Type in "ncol /?" for more information.
Reply 8 years ago on Introduction
It still doesn't work
Reply 8 years ago on Introduction
What exactly are you typing in? Are you still only putting in "ncol"?
Reply 8 years ago on Introduction
He is most likely seeing this:
http://imgur.com/xf0MHJo
As am I! :(
Reply 8 years ago on Introduction
As hard as I try, I can not recreate the issue on my computer. I don't really have any solid ideas as to why it is doing that for you and Mclover, but I will keep trying.
Reply 8 years ago on Introduction
I typed:
ncol "Hello World" 10
8 years ago on Introduction
It didnt work for me :(
Reply 8 years ago on Introduction
It worked for me on Windows 8, 7 and vista. What operating system are you using?