Tip:
Highlight text to annotate it
X
Hello Youtube, today it is my first video with sound.
Many people found my videos too boring, because I just move my mouse and show some batch files.
So I decided to follow their suggestion and do a sound tutorial.
At least it improves my English skills. So, let's get started!
In addition to my previous video 'How to write two texts in one line in batch',
I found out how to use multiple colors in one single CMD-window or in one line.
As this trick is made without any extra software and without editing systemfiles like MSDOS.sys,
it is much more comfortable. The files use the FINDSTR command, so the
'find string' command. For those who don't know: This command searches
files for a particular string. In case of searching an entire directory or
multiple files, it marks the file's name with another color
to keep the overview. The command line is the following...
The color codes behind the /A can be taken from the COLOR command in CMD.
Just type COLOR /? and hit enter. Then the codes will be written over there.
This one is in German, you might do it on your PC and in your language,
just type COLOR /?.
This command, this FINDSTR command, searches every file called 'Text to color'
in the current and lower directories because of the /S.
Each found filename will be colored. As this is not what we want, though, use these
commands: Make Directory ... a unique temp folder,
a temporary folder you call whatever you want, change directory into this folder, in my case
'UniqueTempFolder', create a file called 'Text to color' with
the content 'Text after colored text' by using an ECHO command.
Then use our syntax, switch to the upper directory
and remove the created folder again.
For example if you want to say 'Do not press any key now!',
you call the file 'Do not press any key now!'. The color could be 0C, so background black
and the font red, in this case. This is the first file. The default color
and yellow.
And this is its code: The first commands 'Make directory' and 'Change
directory', then a random output,
then create the file, and use the FINDSTR command
to color an output. Return from the directory and delete it again.
Let's say we want the output to be in the middle of a line.
To do this, it is necessary to have a previous output.
This can be solved by the SET command from the previous video.
SET /P and then the text and the '>nul'.
Again the command row: Make directory, change directory and then
the SET command with the text before the colored text.
Then create the file, use the FINDSTR command again,
switch to the upper directory and remove the folder again.
So, as before, and now green in the middle. Three colors this time.
This is its code: The first two commands again: Make directory,
change directory, the random output, create the first file,
so this is exactly as the first file, the FINDSTR command, then a bunch of blank
lines, then the SET command to have a previous output
before the green, then create the new file and use another FINDSTR
command to have the green output.
Return from the directory and delete it.
We are now able to place the colors whereever we want.
Except for two colors in one line. By using two files and two FINDSTR commands,
it is also possible to have different colors in
one single line. To make this possible, though, it is necessary
to remove the word wrap after the first FINDSTR command.
To do so, the ECHO command needs to be replaced by
a SET command from the previous video.
MD and CD, text before anything by the SET command
and then instead of the ECHO command another SET command.
Creating a file 'Text on to color' with the content 'Text after colored text
one', and create a second file called 'Text 2 to
color' with its content.
Then use the FINDSTR command for the first file
and for the second file. Make a word wrap by using an ECHO. command,
return from the directory and delete it.
So we have the default font
White, green and yellow in one single line: Three colors.
We are now able to do something like this... A table with multiple colors.
Or something like this: the German flag.
The code of this file is easy as well: Change the window size by the MODE CON command,
create a folder and change the directory into this folder,
create the first two files: The heading one and the heading two
by using SET commands, have an output before anything by using another
SET command and use the FINDSTR command to have a colored
output. Then we make a word wrap and have a line...
and then we write the texts. Text one, two, three, four.
And just another line to make it look better. Then return from the directory and delete
it. Just as always.
Oh, by the way, I forgot the third one, I think...
yeah, I did, ehm, just look for yourself: The text before anything, the two files and
the FINDSTR commands.
The only difficulty in the fourth file was to coordinate the spaces.
So if I forgot a space here, the display in the execution will be corrupt.
As you see, it is not right here, so I need to change the code.
Just add a space and execute again and we are done.
In my opinion, it is difficult to read and understand
all these commands in the Windows notepad. So I have written an explanation in my dictionary
(I wrote).
I won't read any word now, just pause the video to read anything.
There are a few disadvantages in this command row:
First there is a colon behind every marked or every colored text.
As you see: Heading one has a colon, heading two has a colon,
text 1:, text 2: and many other colons as well.
The second disadvantage is: It creates files. And also a folder.
Make directory, change directory, the ECHO command and the SET commands.
Third it will be messed up in case there are multiple files containing a particular text.
So if there are two files with the same name and familiar content,
the display will be messed up. The fourth disadvantage is: It will cause
errors if it has not enough rights to create folders or files.
So, the files won't be created,
the FINDSTR command will not work and the entire file will not work.
That it is for today, I'm currently working on a new file that will
be huge, useful and a lot of work. Unfortunately, I won't have much time in the
future, so it might take long until it is finished.
I have only done two-third, yet. I hope you liked it and have fun batching!