How to read from a .properties file using batch script

前端 未结 6 2116
难免孤独
难免孤独 2020-12-15 07:27

I have a requirement where i\'d like to read values from a .properties file

my properties file test.properties content

file=jaguar8
exte         


        
6条回答
  •  忘掉有多难
    2020-12-15 08:09

    @echo off  
    FOR /F "tokens=1,2 delims==" %%G IN (test.properties) DO (set %%G=%%H)  
    echo %file%  
    echo %extension%  
    echo %path%
    

    Note that there is no space after %%H. Else this causes a space to be appended, to file paths for example, and will cause file not found errors when the variables from the property files are used as part of a file path.Struggled for hours because of this!

提交回复
热议问题