Batch file 为什么我的特殊字符在引用批次中不被忽略?

Batch file 为什么我的特殊字符在引用批次中不被忽略?,batch-file,colors,output,echo,Batch File,Colors,Output,Echo,我正在尝试在批处理文件中使用/| \字符创建一些多行、多色ascii艺术 然而,我认为我的批处理纸条是将它们作为命令读取,而不是仅输出文本 *这是基于我在这里找到的一些着色代码: 您正在使用过时的代码,那么。试试这个: @echo off setlocal call :initColorPrint call :ColorPrint 0a "#############################################################################

我正在尝试在批处理文件中使用/| \字符创建一些多行、多色ascii艺术

然而,我认为我的批处理纸条是将它们作为命令读取,而不是仅输出文本

*这是基于我在这里找到的一些着色代码:


您正在使用过时的代码,那么。试试这个:

@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
@echo关闭
setlocal
调用:initColorPrint
摩摩摩托托托托托托托托支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支35月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日35月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日35月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日############”
调用:ColorPrint 1b“/|\”
摩摩摩托托托托托托托托支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支支35月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日35月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日35月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月月日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日日############”
调用:cleanupColorPrint
退出/b
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:彩色打印颜色Str[/n]
setlocal
设置“str=%~2”
调用:colorPrintVar%1 str%3
退出/b
:colorPrintVar Color StrVar[/n]
如果未定义%2退出/b
setlocal enableDelayedExpansion
设置“str=a%DEL%!%2:\=a%DEL%\..\%DEL%%DEL%%DEL%!”
设置“str=!str:/=a%DEL%/..\%DEL%%DEL%%DEL%!”
设置“str=!str:=\!”
pushd“%temp%”
findstr/p/A:%1“!str!\..\x”nul
如果/i“%~3”==“/n”回显(
退出/b
:initColorPrint
对于/F“tokens=1,2 delims=#”%%a in(“'prompt#$H#$E#和echo on&for%%b in(1)do rem””)do set“DEL=%a”
%temp%\x“set/p”=%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%。%DEL%
退出/b
:清除彩色打印
删除“%temp%\x”
退出/b

您不能使用此方法输出文件名中不允许的字符。那么,是否有其他方法可以在包含这些特殊字符的文本上创建多种颜色?按照您最初的链接答案,有。阅读一年后的部分之前没有看到,但这确实有效。谢谢!如果您以如果有答案,我会接受它作为解决方案。
F:\>test
TEST
################################################################################
################################################################################
The system cannot find the path specified.
FINDSTR: Cannot open ^^/^^|^^" nul
################################################################################
################################################################################
F:\>
@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