Does the properies file really contain the spaces between the =
?
Something like this will read all the properies and display their values only:
@echo off
for /f "tokens=2 delims== " %%i in (testing.properties) do echo %%i
pause
where this will display the property name as well as the value:
@echo off
for /f "tokens=1,* delims== " %%i in (testing.properties) do echo Property: %%i Value: %%j
pause
if you really want to set the properties as variables (to use as readable variables).
@echo off
setlocal enabledelayedexpansion
for /f "tokens=1,* delims== " %%i in (testing.properties) do (
set property=%%i
set value=%%j
echo !property! !value!
)
pause
Comparing values and then setting them is another task on its own. Here you are giving an example, so give a real example and we can work from there. For instance. We can set the property name value as the vaiable name without manually typing it:
@echo off
setlocal enabledelayedexpansion
for /f "tokens=1,* delims== " %%i in (testing.properties) do (
set %%i=%%j
echo Property: %%i has Value: !%%i!
)
pause
or even add a something to the string:
@echo off
setlocal enabledelayedexpansion
for /f "tokens=1,* delims== " %%i in (testing.properties) do (
set local_%%i=%%j
echo Property: %%i has value !local_%%i! set as Variable local_%%i
)
pause
Finally, giving your variables unique names will depend on some search criteria, you can probably use identifiers from your properties. For instance do a findstr
on part of your property, or simply matching a numeric value or anything unique in a property.