0

I'm trying to create some multiline, multi color ascii art in my batch file, using /|\ characters.

However, I think my batch scrip is reading them as commands instead of outputting text only.

*This is based on some coloring code I found here: Batch Color per line

@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 TEST

call :ColorText 0a "################################################################################################################################################################"
call :ColorText 1b "^/^|^\" 
call :ColorText 0a "################################################################################################################################################################"

goto :eof

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

The special characters have ^ in front of them, and they are in quotes.

How can I get this to print these special characters for my Ascii Art?

Here is the output I get:

F:\>test
TEST
################################################################################
################################################################################
The system cannot find the path specified.
FINDSTR: Cannot open ^^/^^|^^" nul
################################################################################
################################################################################
F:\>
Community
  • 1
  • 1
level42
  • 842
  • 2
  • 10
  • 29
  • You can not use this method to output a character not allowed in a file name. – MC ND Dec 05 '14 at 15:19
  • Then, is there any alternate way I can create multiple colours on text that contains these special characters? – level42 Dec 05 '14 at 15:24
  • Following your initial linked answer, there is [this](http://stackoverflow.com/a/5344911/2861476). Read the *one year later* section – MC ND Dec 05 '14 at 15:25
  • Did not see that earlier, but this does work. Thanks! If you post that as an answer, I will accept it as the solution. – level42 Dec 05 '14 at 15:28

1 Answers1

0

You're using obsolete code. jeb updated his code, then dbenham updated jeb's update. Try this:

@echo off
setlocal

call :initColorPrint

call :ColorPrint 0a "################################################################################################################################################################"
call :ColorPrint 1b "/|\" 
call :ColorPrint 0a "################################################################################################################################################################"


call :cleanupColorPrint

exit /b

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

: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
Community
  • 1
  • 1
rojo
  • 22,626
  • 5
  • 47
  • 93