Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
mor.bas
- Posts: 66
- Joined: 25 Apr 2012 04:28
#1
Post
by mor.bas » 30 Jun 2013 05:41
hi,
I need a script that I will give it a path to ini file and it will read data there and put the output(increment by one ) in another file (giving by the user )
like : test.bat [path to ini file] [path to output file]
I have something like that right now:
Code: Select all
call:getvalue %INIFILE% "BuildVersion" OUTPUTLEVEL
set /a OUTPUTLEVEL+=1
echo %OUTPUTLEVEL% >"C:\Users\test.txt"
goto:eof
:getvalue
rem This function reads a value from an INI file and stored it in a variable
rem %1 = name of ini file to search in.
rem %2 = search term to look for
rem %3 = variable to place search result
FOR /F "eol=; eol=[ tokens=1,2* delims==" %%i in ('findstr /b /l /i %~2= %1') DO set %~3=%%~j
goto:eof
How to change it to work properly like I need?
Thanks in advance...
-
mor.bas
- Posts: 66
- Joined: 25 Apr 2012 04:28
#3
Post
by mor.bas » 30 Jun 2013 07:15
Yes I should provide the ini file name and the output file name
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#4
Post
by foxidrive » 30 Jun 2013 07:20
if you are changing the build level then batch math is by default only integer math. Is that the problem you have?
What issues are you having?
-
mor.bas
- Posts: 66
- Joined: 25 Apr 2012 04:28
#5
Post
by mor.bas » 30 Jun 2013 07:38
Hi,
I just want to use a coomand line like: test.bat [path to ini file] [path to output file]
test.bat [path to ini file] [path to output file]
ini file and output file are the things that get change.
BuildVersion is only the value the got a varible Like:
Buildversion=45.
Right now I need to write command like :test.bat [path to ini file] [path to output file] "BuildVersion" "" [path to output file] and i want an input like:
test.bat [path to ini file] [path to output file]
-
Aacini
- Expert
- Posts: 1932
- Joined: 06 Dec 2011 22:15
- Location: México City, México
-
Contact:
#6
Post
by Aacini » 30 Jun 2013 08:42
mor.bas wrote:I have something like that right now:
Code: Select all
call:getvalue %INIFILE% "BuildVersion" OUTPUTLEVEL
Solution:
Code: Select all
:getvalue inputFile term result=
for /F "delims=" %%a in ('findstr %2 %1') do set %%a
set /A %3=%~2+1
exit /B
This code assume that the value in the .ini file have the format of an assignment, for example:
If the format is different, a small modification is needed.
In order to complete the original request:
mor.bas wrote:like : test.bat [path to ini file] [path to output file]
Just complete it this way:
Code: Select all
@echo off
rem test.bat [path to ini file] [path to output file]
for /F "delims=" %%a in ('findstr BuildVersion %1') do set %%a
set /A OUTPUTLEVEL=BuildVersion+1
echo OUTPUTLEVEL=%OUTPUTLEVEL%> %2
Antonio