Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Save an ini file as its first line
Name: Ryanoc3ros Date: May 8, 2009 at 22:51:37 Pacific OS: Windows Vista Subcategory: Batch
Comment:
I have a ini file containing the following information.
Name: Mechanix2Go Date: May 8, 2009 at 23:07:16 Pacific
Reply:
:: extract value of first ver in my.ini and rename ini :: exthello Sat 09-05-2009 12:59:36.85
@echo off & setLocal EnableDelayedExpansion
for /f "tokens=2 delims==" %%a in ('find "variable" ^< my.ini') do ( if not defined new set new=%%a )
echo ren my.ini !new!.txt
===================================== If at first you don't succeed, you're about average.
M2
0
Response Number 2
Name: Ryanoc3ros Date: May 8, 2009 at 23:42:01 Pacific
Reply:
Thanks a lot! This works good for when the variable is just one word. I cant seem to figure out how to properly rename a file if the variable is equal to two words with a space.
0
Response Number 3
Name: Ryanoc3ros Date: May 8, 2009 at 23:45:52 Pacific
Reply:
Nevermind, I got it. Thanks for your help!
0
Response Number 4
Name: Mechanix2Go Date: May 9, 2009 at 00:09:42 Pacific
Reply:
@echo off & setLocal EnableDelayedExpansion
for /f "tokens=2 delims==" %%a in ('find "variable" ^< my.ini') do ( if not defined new set new=%%a )
echo ren my.ini "!new!.txt"
===================================== If at first you don't succeed, you're about average.
M2
0
Response Number 5
Name: ghostdog Date: May 9, 2009 at 00:22:42 Pacific
Reply:
if you find yourself parsing ini files often (or not) , its ok to use an ini parser, such as those from Perl, or Python (and others) an eg done with Python
import ConfigParser
config = ConfigParser.ConfigParser()
config.read("file")
for section in config.sections():
if section == "Meter1":
if "variable_1" in config.options(section):
print config.get(section, "variable_1")
output:
c:\test> more file
[Meter1]
variable_1=Hello world
variable_2=World
variable_3=Goodbye
c:\test> python test.py
Hello world
Summary: Maybe you can try this free application.It let you: Manipulate with an INI-file and its elements by the easiest way from any programming language. The INI-File Manager ActiveX can be used from VB, VB...
Summary: Hi, I was wondering if anyone knew how I can prevent people from saving an HTML file with an image on it (jpeg) from within a browser? I'm mainly concerned about people saving the image, since it is r...
Summary: need to edit line an ini file as part of an install, by running a batch. Is this possible please? e.g change [settings] IP=xx.xx.xx.xx DSN=xxxxxxx to [settings] IP=yyy.yy.yy.yy DSN=wwwwwwww ...