Page 1 of 1

Changing the color of each line of output?

Posted: 27 May 2013 20:59
by tbharber
Hey all!

I have a script that looks for a series of files. If they are found I want it to change the color of just that line to be green, and if it is not found, to be red. Below is a simplified version of the code I currently have. The problem is say file 1 is found and it is green, and if file 2 is missing, all of the text on the screen turns red instead of just that one line. What is the easiest way to have just the lines of the files that do not exist to be red, and the rest green?


Code: Select all

@echo off
cls
if exist c:\test1.txt (color 1a & echo File Exists) else (color 1c & echo File Missing)
if exist c:\test2.txt (color 1a & echo File Exists) else (color 1c & echo File Missing)
if exist c:\test3.txt (color 1a & echo File Exists) else (color 1c & echo File Missing)
if exist c:\test4.txt (color 1a & echo File Exists) else (color 1c & echo File Missing)

Re: Changing the color of each line of output?

Posted: 27 May 2013 23:25
by Endoro

Re: Changing the color of each line of output?

Posted: 28 May 2013 10:02
by Aacini
You may use my ColorShow.exe auxiliary program that run much faster than Batch solutions. For example:

Code: Select all

if exist c:\test1.txt (ColorShow /1a "File Exists") else (ColorShow /1c "File Missing")
if exist c:\test2.txt (ColorShow /1a "File Exists") else (ColorShow /1c "File Missing")
if exist c:\test3.txt (ColorShow /1a "File Exists") else (ColorShow /1c "File Missing")
if exist c:\test4.txt (ColorShow /1a "File Exists") else (ColorShow /1c "File Missing")

Look for file 12-ColorShow.exe.hex at this site.

Antonio