차순주
차순주

Reputation: 3

batch read ini values

I'm started study about batch and i got a problem

i have one ini file

sample.ini

[Path_Info]
path1=c:\one
path2=c:\two

sample.bat

FOR /F "tokens=*" %%A IN ('type "sample.ini"') DO SET %%A
:True ( 
 xcopy %path1%\*.* %BU_Temp%\%name1% /e /h /k /y /i /s /d:%M%-%D%-%Y%
 xcopy %path2%\*.* %BU_Temp%\%name2% /e /h /k /y /i /s /d:%M%-%D%-%Y%
 )

At that time i want use 'for' to xcopy and make one line?

so i try to xcopy %path%%i%~~ , xcopy %path%%%I and xcopy %path*% .... anyway

but I failed.. please help me/

I'm not good in english.. sorry

Upvotes: 0

Views: 2432

Answers (1)

user7818749
user7818749

Reputation:

Use delims to split at the equal sign = the n tokens should be 1,2 or 1,* meaning %%a will be assigned to the text before the = and %%b will be assigned to the text after =

@echo off
setlocal enabledelayedexpansion
For /F "tokens=1,*delims==" %%a in ('type "sample.ini"') DO (
    set pathvar=%%b
    echo !pathvar!
)

There is more you need to do still to get it to copy to the correct directories as each path seems to go to another %name% in your case.

Upvotes: 1

Related Questions