Quotations in Batch File Parameters

Q

How to use quotations in double-quote pairs in batch file parameters?

✍: FYIcenter.com

A

Quotations in double-quote pairs in batch file parameters take higher precedence than space characters. So if a space character is inside a quotation, it will be taken as part of a parameter, not as a delimiter to separate parameters.

For example, the following commands invokes the batch file with one parameter only:

```C:\fyicenter>Batch-File-Parameters.bat "a b"
(Batch-File-Parameters.bat)
("a b") () () () ()
("a b")

C:\fyicenter>Batch-File-Parameters.bat "a b c"
(Batch-File-Parameters.bat)
("a b c") () () () ()
("a b c")

C:\fyicenter>Batch-File-Parameters.bat " a b c "
(Batch-File-Parameters.bat)
(" a b c ") () () () ()
(" a b c ")

C:\fyicenter>Batch-File-Parameters.bat "  a  b  c  "
(Batch-File-Parameters.bat)
("  a  b  c  ") () () () ()
("  a  b  c  ")
```

2021-11-12, 1206👍, 0💬