

Mark Yocom has more on this technique here. The ^ escape character can be used to make long commands more readable by splitting them into multiple lines and escaping the Carriage Return + Line Feed (CR/LF) at the end of a line: ROBOCOPY \\FileServ1\e$\users ^ (Many thanks to Jeb who explained this over in the forum better than I could.) Escaping CR/LF line endings. In this version, the first caret escapes the second caret '^', the third caret escapes the '&' so now the new cmd instance inherits ^&

So the new cmd instance would be passed THIS ^& THAT and everything would work? Not so fast, with two carets together, the first will escape the second, meaning that the & is no longer escaped at all. When piping or redirecting text, applying an escape character gets a little more complex, a pipe will start two new cmd.exe instances, each of these cmd processes are passed one side of the pipe and will parse their part once again (with the cmd-line parser, not with the batch-line-parser). Echo THIS ^& THATĮcho The Escape character looks like this ^^ Escape and the pipeline These characters which normally have a special meaning can be escaped and then treated like regular characters : & \ ^ | e.g. Escape Character ^ Escape character.Īdding the escape character before a command symbol allows it to be treated as ordinary text. If you use %* to refer to all parameters, the value returned will include the delimiters.
#Caret character series
When using the TAB character as a delimiter be aware that many text editors will insert a TAB as a series of SPACEs. When FOR /F is used to process a string, the default delimters are Space and TAB. The default token delimiters in a FOR IN() clause are the same as on the command line but the delims= option is available to specify something different. This is because batch file parameters are passed to CMD.exe which can accept it's own parameters (which are invoked using / and - ) Notice that although / and - are commonly used to separate command options, they are absent from the list above. If you are passing a parameter to a batch file that contains any of these delimiter characters, it will split the parameter into two parameters unless you surround the whole thing with double quotes: "this is one=param," Parameters are most often separated by spaces, but any of the following are also valid delimiters:

Delimitersĭelimiters separate one parameter from the next - they split the command line up into words.
#Caret character windows
How-to: Escape Characters, Delimiters and Quotes at the Windows command line.
