When I try
@echo off
set PTag=^<BR^>
echo %PTag%
I get nothing.
Now what's interesting is that if there's an empty line after the last echo, I get:
The syntax of the command is incorrect.
If I remove the @echo off, then it actually outputs
echo <BR>
I want to add various HTML tags inside variables and then concatenate these variables to create an HTML that I will output in a file.
Use double percent signs ( %% ) to carry out the for command within a batch file. Variables are case sensitive, and they must be represented with an alphabetical value such as %a, %b, or %c. Required. Specifies one or more files, directories, or text strings, or a range of values on which to run the command.
So %%k refers to the value of the 3rd token, which is what is returned.
Java Prime Pack Content writing to files is also done with the help of the double redirection filter >>. This filter can be used to append any output to a file. Following is a simple example of how to create a file using the redirection command to append data to files.
The /P switch allows you to set the value of a variable to a line of input entered by the user. Displays the specified promptString before reading the line of input. The promptString can be empty.
set PTag=^<BR^>
sets the value <BR>
to PTag
When you run echo %PTag%
it expands to echo <BR>
which is an invalid redirection. You need to escape the <
and >
inside PTag
by using this
set PTag=^^^<BR^^^>
The first ^
escapes itself, then the next one escapes <
or >
You can also use this
set "PTag=^<BR^>"
Reason for the second way: inside quotes ^
loses its special meaning
If it is a quote (
"
) toggle the quote flag, if the quote flag is active, the following special characters are no longer special:^ & | < > ( )
.
How does the Windows Command Interpreter (CMD.EXE) parse scripts?
most special characters (
^
&
(
)
<
>
|
and also the standard delimiters,
;
=
SPACE TAB) lose their particular meaning as soon as ther are placed in between""
, and the""
themselves do not become part of the variable value
Special Characters in Batch File
Now the variable will have the value ^<BR^>
inside it, and it'll expand echo %PTag%
to
echo ^<BR^>
which is a valid command
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With