1.

Solve : how to set the date in my ini file using a batch file??

Answer»

Well I just needed to know what came before what the OP already posted, but now I am thinking that even with that what I was planning on posting would not work anyway. why not use type and find on a for loop
to find the link
and no i dont have an example because i dont have an exact idea how 2 do itQuote from: smeezekitty on September 09, 2009, 08:16:43 PM

why not use type and find on a for loop
to find the link
and no i dont have an example because i dont have an exact idea how 2 do it
??you could try the following as a template for your issue.

the code will need to be changed to work for what you are wanting to do but:

Code: [Select]
set name=[name of ini file]

for /f "tokens=*" %%a in (%name%) do call :AddText "%%a

ECHO JOB COMPLETE.....
PAUSE

:AddText %1
set Text=%~1%
IF NOT "%Text%"=="<CURR_NUMBER NUMBER="425" TDATE="01/09/2009" /> " ECHO %Text% >> %name%
if "%Text%"=="<CURR_NUMBER NUMBER="425" TDATE="01/09/2009" /> " " ECHO "<CURR_NUMBER NUMBER="1000" TDATE=%date:~4% />" >> %name%
EXIT /b

QUOTE from: wbrost on September 10, 2009, 09:39:04 AM
you could try the following as a template for your issue.

the code will need to be changed to work for what you are wanting to do but:

Code: [Select]
set name=[name of ini file]

for /f "tokens=*" %%a in (%name%) do call :AddText "%%a

ECHO JOB COMPLETE.....
PAUSE

:AddText %1
set Text=%~1%
IF NOT "%Text%"=="<CURR_NUMBER NUMBER="425" TDATE="01/09/2009" /> " ECHO %Text% >> %name%
if "%Text%"=="<CURR_NUMBER NUMBER="425" TDATE="01/09/2009" /> " " ECHO "<CURR_NUMBER NUMBER="1000" TDATE=%date:~4% />" >> %name%
exit /b


are you sure it works the next time the script is run on a different date?the script pulls the current date from the %date:~4%. Unless I am missing something or the SYSTEM date is not correct it will pull the correct date.

Please let me know if I over looked something or if there is a better way to do this type of thing in batch.Quote from: wbrost on September 10, 2009, 11:16:40 AM
the script pulls the current date from the %date:~4%. Unless I am missing something or the system date is not correct it will pull the correct date.

Please let me know if I over looked something or if there is a better way to do this type of thing in batch.
in this portion of code
Quote
Code: [Select]if "%Text%"=="<CURR_NUMBER NUMBER="425" TDATE="01/09/2009" />
you hardcoded the date. I was asking, what if the date changed becomes 02/09/2009 and when the script is run the next time, it won't find 01/09/2009 anymore , right? therefore your "If" statement above would not be executed. (or have i misunderstood your code?)
also, there is never a guarantee that every date SETTINGS the OP runs his script in is the same as yours. Hi,

I don't want the value of CURR_NUMBER to be checked against 425 because it's only a dummy value.
The code should set the value of CURR_NUMBER to 1000 and TDATE to current date.

I was just wondering if this can be achieved through a batch file so that i can put it in my Start Up folder and it gets executed when i boot my PC.

Any ideas?Quote from: rajesh_38 on September 09, 2009, 12:42:28 AM
Hello,

Can anyone PLS help me in setting the values in my .ini file using a batch file?
My ini file looks like this
<TB_DATE>
<CURR_NUMBER NUMBER="425" TDATE="01/09/2009" />
</TB_DATE>
@echo off
For /f "tokens=1,3,5 delims="" %%a in ('type file.ini') do (
If "%%a"==" >>newfile.ini) else (echo %%a>>newfile.ini)
)
Now, I need to know 2 things before I can make this code work. (I'm not sure it will work anyway)

1. What is the ENTIRE contents of the file IF there are any " after the part you gave me.
2. What do you see when you run ECHO %time% at the command prompt. @helpmeh, have you run that batch yet? echo %time% gives me time in hh:mm:ss.dd but i do not require time to be set.It's only the date.

Looks like there is no way this can be achieved through a batch file...


Discussion

No Comment Found