每行批次色差 [英] Batch Color per line

查看:166
本文介绍了每行批次色差的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在批,你能有每行不同的颜色。
例如,如果你有一个批处理文件说
你好
你怎么样?

In batch, can you have different colors per line. For example if you had a batch file say "Hello" "How are you?"

你可以在蓝色的你好和你好吗,在绿色的吗?

Could you have "Hello" in blue and "How are you" in green?

(我知道颜色命令的方式,以及它的颜色既背景和文本)

(I know about the color command, and the way it colors both the background and the text)

推荐答案

您可以不用任何外部的程序。这里是我以前走过来了两天的东西。作品非常好。

You can do it without any external program. Here is something that I came over a couple of days ago. Works very good.

@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"
)
echo say the name of the colors, don't read

call :ColorText 0a "blue"
call :ColorText 0C "green"
call :ColorText 0b "red"
echo(
call :ColorText 19 "yellow"
call :ColorText 2F "black"
call :ColorText 4e "white"

goto :eof

:ColorText
echo off
<nul set /p ".=%DEL%" > "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1
goto :eof

Credits to jeb
His post can be found here

这篇关于每行批次色差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆