Search This Blog

Windows Batch Script: comma in command arguments

Comma (or semicolon) in command arguments, if not quoted, are considered separators (same as white space). See the script (named test.bat) below:
@echo off
:loop
if not "%~1"=="" (
    echo %~1 
    shift
    goto :loop
)
When calling the script,
if not quoted:
test.bat 1,2,3
1
2
3



if quoted:
test.bat "1,2,3"
1,2,3

No comments:

Post a Comment