Parsing string in batch file

后端 未结 3 1028
萌比男神i
萌比男神i 2020-12-16 20:01

I have the following string:

MyProject/Architecture=32bit,BuildType=Debug,OS=winpc

I would like to be able to grab the values 32bit, Debug, and

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-16 20:43

    This should do it:

    FOR /F "tokens=1-6 delims==," %%I IN ("MyProject/Architecture=32bit,BuildType=Debug,OS=winpc") DO (
        ECHO I %%I, J %%J, K %%K, L %%L, M %%M, N %%N
    )
    REM output is: I MyProject/Architecture, J 32bit, K BuildType, L Debug, M OS, N winpc
    

    The batch FOR loop is a pretty interesting piece of machinery. Type FOR /? in a console for a description of some of the crazy stuff it can do.

提交回复
热议问题