how to call a path from .ini file into bat command string?

Posted on

Problem :

I have a .ini file called job1.ini and this .ini contains information which I need to work with by injecting it on a specific spot in my batch script.

batch script is in the same folder as my .ini file

content of job1.ini:

[JobSet]

Codec=hevc

Video=E:folderB 1.265

VideoWidth=1920

VideoHeight=1080

my script:

“C:Tempmkvmerge.exe” -o “E:done.mkv” –title “B 1” “here_I_need_that_path_from_ini” “C:Tempaudio.flac”

also I found this:

for /f “tokens=2 delims==” %%a in (‘findstr Video job1.ini’) do set
Video=%%a

how could I combine these 3 pieces, so my script would work??

Solution :

Your line:

for /f "tokens=2 delims==" %%a in ('findstr Video job1.ini') do set Video=%%a

can’t work because findstr will also match the Videoheight/VideoWidth entries and have the resulting environment variable Video=1080

Try this (untested):

@Echo off&SetLocal EnableExtensions EnableDelayedExpansion
Set "Video="
for /f "delims=" %%a in ('findstr /i "^Video=" job1.ini') do set "%%a"
if defined Video "C:Tempmkvmerge.exe" -o "E:done.mkv" --title "B 1" "%Video%" "C:Tempaudio.flac"

Leave a Reply

Your email address will not be published. Required fields are marked *