Changing the color of each line of output?
Posted: 27 May 2013 20:59
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?
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)