Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do Batch files support multiline variables

If so How?

Yes, batch files are lame, but I cannot use powershell, and I don't feel like writing a real app to do this simple task....

edit

What i want is somthing along the lines of

set var="this is a  multi  line  string " 
like image 558
Byron Whitlock Avatar asked Jul 20 '10 21:07

Byron Whitlock


People also ask

How many arguments can be passed to a batch file?

There is no practical limit to the number of parameters you can pass to a batch file, but you can only address parameter 0 (%0 - The batch file name) through parameter 9 (%9).

What does %% mean in batch file?

Represents a replaceable parameter. Use a single percent sign ( % ) to carry out the for command at the command prompt. 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. ( <set> )

Can a batch file take arguments?

Batch scripts support the concept of command line arguments wherein arguments can be passed to the batch file when invoked. The arguments can be called from the batch files through the variables %1, %2, %3, and so on.


2 Answers

Or you can create a "real" newline character.

setlocal enableDelayedExpansion set NL=^   rem two empty line required echo first line !NL! second line set multi=Line1!NL!Line2 set multi=!multi!!NL!Line3 echo !Multi! 

With this variant the newline is a "normal" character in the string, so the variables act normally and you can assign them to another variable, this is not possible with the &echo. trick (which is useful for simple tasks).

like image 103
jeb Avatar answered Oct 05 '22 22:10

jeb


Is that ok?

@echo off set var=kur set var2=kur2 echo var is = "%var%" and var2 is = %var2% 

edit
is that what you mean ?

@echo off set nl=^& echo. echo this%nl%is%nl%multiline%nl%string 
like image 27
T1000 Avatar answered Oct 05 '22 22:10

T1000