marlon1
Goto Top

Farbe in Batch

Hallo,
Ich hatte schon einmal eine Frage hier gestellt und habe auch sehr schnell eine Antwort bekommen und da dachte ich mir ich stelle noch eine Frage.
So jetzt zur Frage:
Bekommt man es in Batch hin nur BESTIMMTE Wörter in Batch farbig zu machen?

MfG Marlon face-smile

Content-Key: 291483

Url: https://administrator.de/contentid/291483

Printed on: April 24, 2024 at 23:04 o'clock

Mitglied: 114757
Solution 114757 Dec 21, 2015 updated at 17:35:29 (UTC)
Goto Top
Moin,
geht face-smile

Quelle: Funktionen stammen von http://www.dostips.com/forum/viewtopic.php?f=3&t=4018
@echo off & setlocal
call :initColorPrint

call :colorPrint 0c "Das "  
call :colorPrint 0e "ist "  
call :colorPrint 09 "ein "  
call :colorPrint 0b "Test"  

call :cleanupColorPrint
exit /b

REM ####### FUNKTIONEN ##################
:colorPrint Color  Str  [/n]
setlocal
set "str=%~2"  
call :colorPrintVar %1 str %3
exit /b

:colorPrintVar  Color  StrVar  [/n]
if not defined %~2 exit /b
setlocal enableDelayedExpansion
set "str=a%DEL%!%~2:\=a%DEL%\..\%DEL%%DEL%%DEL%!"  
set "str=!str:/=a%DEL%/..\%DEL%%DEL%%DEL%!"  
set "str=!str:"=\"!"  
pushd "%temp%"  
findstr /p /A:%1 "." "!str!\..\x" nul  
if /i "%~3"=="/n" echo(  
exit /b

:initColorPrint
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do set "DEL=%%a"  
<nul >"%temp%\x" set /p "=%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%.%DEL%"  
exit /b

:cleanupColorPrint
del "%temp%\x"  
exit /b
Gruß jodel32
Member: Marlon1
Marlon1 Dec 21, 2015 at 17:11:25 (UTC)
Goto Top
Danke, geht super!
Member: Snowman25
Snowman25 Dec 21, 2015 at 17:25:32 (UTC)
Goto Top
Ist das selektive Colorierung durch Backspacing in reinem batch?

Respekt!
Mitglied: 114757
114757 Dec 21, 2015 updated at 17:36:07 (UTC)
Goto Top
Die Funktion stammt aus dem DOS-Tips Forum, hatte ich noch vergessen einzutragen, Quelle ist oben ergänzt:
http://www.dostips.com/forum/viewtopic.php?f=3&t=4018
Member: rubberman
rubberman Dec 21, 2015 at 18:13:07 (UTC)
Goto Top
Die Kolorierung ist um FINDSTR /A gescriptet. Backspacing wird benötigt um Zeichen zu supporten, die in Windows-Pfaden nicht erlaubt sind und um nur die gewünschte Zeichen im Konsolefenster stehen zu lassen.

Grüße
rubberman