Computing.Net > Forums > Programming > Exstracting part of a line in a ini file

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.

Exstracting part of a line in a ini file

Reply to Message Icon

Name: alana257
Date: May 8, 2009 at 15:39:21 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

Hi,

I need to exstract part of a line from a ini file and use it later on.

Within the ini file i need to find:

Keyfile: P:\notes\notes.id

but all i need is the P:\notes\notes.id.

how do i exstract just the file location (so i can copy it to another location) using a batch file?

Please help

Alana257



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: May 8, 2009 at 20:49:18 Pacific
Reply:

@echo off > newfile & setLocal EnableDelayedExpansion

for /f "tokens=2 delims= " %%a in (myfile) do (
echo %%a
)


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 2
Name: Valerie (by Garibaldi)
Date: May 9, 2009 at 01:41:38 Pacific
Reply:

Untested...

@echo off
cls
setlocal enabledelayedexpansion

for /f "delims=" %%1 in (filename.ini) do (
    set line=%%1 & call :checkit
)

:checkit
if /I "!line:~0,7!"=="Keyfile" (
   for /f "tokens=1-2* delims= " %%2 in ("!line!") do (
   set file=%%3
   goto continue
   ))
   goto :eof

:continue
:: Other coding here...


0

Response Number 3
Name: alana257
Date: May 11, 2009 at 02:38:33 Pacific
Reply:

Thanks for the Code, Could you give me an exaple if it working?

I need the location of the ID file so i can copy the ID file to another location on the HDD/Network

Alan


0

Response Number 4
Name: Valerie (by Garibaldi)
Date: May 11, 2009 at 03:14:01 Pacific
Reply:

What do you mean Could you give me an exaple if it working? Have you tested the script to ensure that it outputs what you want? The path to the .ID file (P:\notes\notes.id) should be available in the %file% variable. You will have to enter the path\name of the .INI file.

Once you have ensured that the script output is what you want you can then go on to add code in the :Continue sub to do the copying.

V.


0

Response Number 5
Name: alana257
Date: May 11, 2009 at 04:01:32 Pacific
Reply:

Currently i have

@echo off
cls
setlocal enabledelayedexpansion

for /f "delims=" %%1 in (c:\temp\notes.ini) do (
set line=%%1 & call :checkit
)

:checkit
if /I "!line:~0,7!"=="Keyfile" (
for /f "tokens=1-2* delims= " %%2 in ("!line!") do (
set file=%%3
goto continue
))
goto :eof

:continue

echo %file%


Copy (Notes ID Path) c:\users\%username%\Notes\Data\%username%.ID

but it doesn't come out with any output
I apologise for my Stupidity but i'm not an expert with batch files.


0

Related Posts

See More



Response Number 6
Name: Valerie (by Garibaldi)
Date: May 12, 2009 at 01:33:24 Pacific
Reply:

I made up relevant files and the script worked perfectly.

Does the script echo the correct path\filename and when you add your Copy command is the file copied to whatever destination you supply?

Add the following lines in the :continue sub:

copy %file% c:\temp\trialfile.txt > nul
dir c:\temp\trialfile.txt

If the dir listing for c:\temp\trialfile.txt is ok then everything is performing correctly.

Edit: Just re-read your last response. "but it doesn't come out with any output"

Are you expecting an on-screen display? If so, Copy is the wrong command. Please advise.



0

Response Number 7
Name: alana257
Date: May 12, 2009 at 01:52:26 Pacific
Reply:

Hi,

I ran the code including the above with Echo ON and this is what it showed

G:\>goto :eof

G:\>(set line=WindowSizeBrowseAlarms=369 162 541 282   & call :checkit )

G:\>if /I "!line:~0,7!" == "Keyfile" (for /F "tokens=1-2* delims= " %2 in ("!lin
e!") do (
set file=%3
 goto continue
) )

G:\>goto :eof

G:\>(set line=URLAddress3=http://172.18.22.98:8080/TeamStructure/navigator.jsp
 & call :checkit )

G:\>if /I "!line:~0,7!" == "Keyfile" (for /F "tokens=1-2* delims= " %2 in ("!lin
e!") do (
set file=%3
 goto continue
) )

G:\>goto :eof

G:\>(set line=URLAddress4=\\a3kssl0j1\p\work\drivers   & call :checkit )

G:\>if /I "!line:~0,7!" == "Keyfile" (for /F "tokens=1-2* delims= " %2 in ("!lin
e!") do (
set file=%3
 goto continue
) )

G:\>goto :eof

G:\>(set line=URLAddress5=http://www.moddb.com/mods/10531/no-limit-mod/downloads
/10555/no-limit-mod-soulstorm   & call :checkit )

G:\>if /I "!line:~0,7!" == "Keyfile" (for /F "tokens=1-2* delims= " %2 in ("!lin
e!") do (
set file=%3
 goto continue
) )

G:\>goto :eof

G:\>(set line=URLAddress6=http://forums.relicnews.com/showthread.php?t=185954
& call :checkit )

G:\>if /I "!line:~0,7!" == "Keyfile" (for /F "tokens=1-2* delims= " %2 in ("!lin
e!") do (
set file=%3
 goto continue
) )

G:\>goto :eof

G:\>(set line=URLAddress7=http://forums.filefront.com/dawn-war-dark-crusade-gene
ral-discussion/320839-how-increase-unit-cap.html   & call :checkit )

G:\>if /I "!line:~0,7!" == "Keyfile" (for /F "tokens=1-2* delims= " %2 in ("!lin
e!") do (
set file=%3
 goto continue
) )

G:\>goto :eof

G:\>(set line=WindowSizeACLAddUser=486 162 307 112   & call :checkit )

G:\>if /I "!line:~0,7!" == "Keyfile" (for /F "tokens=1-2* delims= " %2 in ("!lin
e!") do (
set file=%3
 goto continue
) )

G:\>goto :eof

G:\>(set line=SelectNamesDialogSize=214,810,162,509,   & call :checkit )

G:\>if /I "!line:~0,7!" == "Keyfile" (for /F "tokens=1-2* delims= " %2 in ("!lin
e!") do (
set file=%3
 goto continue
) )

G:\>goto :eof

G:\>(set line=SPELL_DLL=ltspln50.dll   & call :checkit )

G:\>if /I "!line:~0,7!" == "Keyfile" (for /F "tokens=1-2* delims= " %2 in ("!lin
e!") do (
set file=%3
 goto continue
) )

G:\>goto :eof

G:\>(set line=SPELL_DIR=g:\notes\data   & call :checkit )

G:\>if /I "!line:~0,7!" == "Keyfile" (for /F "tokens=1-2* delims= " %2 in ("!lin
e!") do (
set file=%3
 goto continue
) )

G:\>goto :eof

G:\>(set line=WindowSizeNewDatabase=445 134 389 427   & call :checkit )

G:\>if /I "!line:~0,7!" == "Keyfile" (for /F "tokens=1-2* delims= " %2 in ("!lin
e!") do (
set file=%3
 goto continue
) )

G:\>goto :eof

G:\>(set line=$CreateBookmarkLastFolder=Favorite Bookmarks   & call :checkit )

G:\>if /I "!line:~0,7!" == "Keyfile" (for /F "tokens=1-2* delims= " %2 in ("!lin
e!") do (
set file=%3
 goto continue
) )

G:\>goto :eof

G:\>(set line=WindowSizeBookmark=453 162 374 302   & call :checkit )

G:\>if /I "!line:~0,7!" == "Keyfile" (for /F "tokens=1-2* delims= " %2 in ("!lin
e!") do (
set file=%3
 goto continue
) )

G:\>goto :eof

G:\>(set line=WindowSizeOpenDoc=366 134 548 290   & call :checkit )

G:\>if /I "!line:~0,7!" == "Keyfile" (for /F "tokens=1-2* delims= " %2 in ("!lin
e!") do (
set file=%3
 goto continue
) )

G:\>goto :eof

G:\>(set line=$outlineServer=DCCMAIL1   & call :checkit )

G:\>if /I "!line:~0,7!" == "Keyfile" (for /F "tokens=1-2* delims= " %2 in ("!lin
e!") do (
set file=%3
 goto continue
) )

G:\>goto :eof

G:\>(set line=URLAddress8=http://www.ocia.net/reviews/icybox4220/page4.shtml   &
 call :checkit )

G:\>if /I "!line:~0,7!" == "Keyfile" (for /F "tokens=1-2* delims= " %2 in ("!lin
e!") do (
set file=%3
 goto continue
) )

G:\>goto :eof

G:\>(set line=WindowSizeCalendarEmodal=336 162 608 515   & call :checkit )

G:\>if /I "!line:~0,7!" == "Keyfile" (for /F "tokens=1-2* delims= " %2 in ("!lin
e!") do (
set file=%3
 goto continue
) )

G:\>goto :eof

G:\>(set line=URLAddress9=http://forums.relicnews.com/archive/index.php/t-38722.
html   & call :checkit )

G:\>if /I "!line:~0,7!" == "Keyfile" (for /F "tokens=1-2* delims= " %2 in ("!lin
e!") do (
set file=%3
 goto continue
) )

G:\>goto :eof

G:\>(set line=URLAddress10=http://news.bbc.co.uk/1/hi/world/south_asia/7240939.s
tm   & call :checkit )

G:\>if /I "!line:~0,7!" == "Keyfile" (for /F "tokens=1-2* delims= " %2 in ("!lin
e!") do (
set file=%3
 goto continue
) )

G:\>goto :eof

G:\>(set line=DYNINFOCR_OFA1FF98F1:74779A54-ON06B32EAB:25F70C7E=OFB198D2D6:3B5FA
8BC-ON4FAF83E3:A4558EEC   & call :checkit )

G:\>if /I "!line:~0,7!" == "Keyfile" (for /F "tokens=1-2* delims= " %2 in ("!lin
e!") do (
set file=%3
 goto continue
) )

G:\>goto :eof

G:\>(set line=RoamingUpgrade=0   & call :checkit )

G:\>if /I "!line:~0,7!" == "Keyfile" (for /F "tokens=1-2* delims= " %2 in ("!lin
e!") do (
set file=%3
 goto continue
) )

G:\>goto :eof

G:\>(set line=FINDSTRING0=ricoh   & call :checkit )

G:\>if /I "!line:~0,7!" == "Keyfile" (for /F "tokens=1-2* delims= " %2 in ("!lin
e!") do (
set file=%3
 goto continue
) )

G:\>goto :eof

G:\>(set line=FINDSTRING1=richoh   & call :checkit )

G:\>if /I "!line:~0,7!" == "Keyfile" (for /F "tokens=1-2* delims= " %2 in ("!lin
e!") do (
set file=%3
 goto continue
) )

G:\>goto :eof

G:\>(set line=WindowMoreStateSearch=0   & call :checkit )

G:\>if /I "!line:~0,7!" == "Keyfile" (for /F "tokens=1-2* delims= " %2 in ("!lin
e!") do (
set file=%3
 goto continue
) )

G:\>goto :eof

G:\>(set line=SU_IN_PROGRESS=0   & call :checkit )

G:\>if /I "!line:~0,7!" == "Keyfile" (for /F "tokens=1-2* delims= " %2 in ("!lin
e!") do (
set file=%3
 goto continue
) )

G:\>goto :eof

G:\>(set line=SU_NEXT_UPDATE=13/05/2009 08:27:42   & call :checkit )

G:\>if /I "!line:~0,7!" == "Keyfile" (for /F "tokens=1-2* delims= " %2 in ("!lin
e!") do (
set file=%3
 goto continue
) )

G:\>goto :eof

G:\>(set line=SU_FILE_CLEANUP=C:\DOCUME~1\ALANP~1.ARM\LOCALS~1\Temp\smkits   & c
all :checkit )

G:\>if /I "!line:~0,7!" == "Keyfile" (for /F "tokens=1-2* delims= " %2 in ("!lin
e!") do (
set file=%3
 goto continue
) )

G:\>goto :eof

G:\>(set line=SUT_NEXT_UPDATE=13/05/2009 08:27:42   & call :checkit )

G:\>if /I "!line:~0,7!" == "Keyfile" (for /F "tokens=1-2* delims= " %2 in ("!lin
e!") do (
set file=%3
 goto continue
) )

G:\>goto :eof

G:\>if /I "!line:~0,7!" == "Keyfile" (for /F "tokens=1-2* delims= " %2 in ("!lin
e!") do (
set file=%3
 goto continue
) )

G:\>goto :eof

G:\>

It looks like it doesn't get to the Keyfilename.


0

Response Number 8
Name: Valerie (by Garibaldi)
Date: May 12, 2009 at 16:40:34 Pacific
Reply:

Can you post the contents of your .ini file please?


0

Response Number 9
Name: alana257
Date: May 13, 2009 at 01:12:23 Pacific
Reply:

Hi Val,

Here you go

[NOTES]
Directory=g:\notes\data
FaultRecovery_Build=Release 7.0.1
Timezone=0
DSTLAW=3,-1,1,10,-1,1
DST=1
MailType=0
$$HasLANPort=1
WWWDSP_SYNC_BROWSERCACHE=0
WWWDSP_PREFETCH_OBJECT=0
EnableJavaApplets=1
EnablePlugins=1
Preferences=1082150001
PhoneLog=2
Log=log.nsf, 1, 0, 7, 40000
AltNameLanguage=en
ContentLanguage=en
WeekStart=2
ViewWeekStart=2
NavWeekStart=2
XLATE_CSID=52
SPELL_LANG=1033
SPELL_PREFERENCES=0
Region=en
DatePickerDirection=0
Passthru_LogLevel=0
Console_LogLevel=2
VIEWIMP1=Lotus 1-2-3,0,_IWKSV,,.123,.WK1,.WK3,.WK4,.WKS,.WR1,.WRK,,4,
VIEWIMP2=Structured Text,0,_ISTR,,.CGN,.LTR,.STR,._UNKNOWN,,,1,
VIEWIMP3=Tabular Text,0,_ITAB,,.PRN,.RPT,.TAB,.TXT,,1,
VIEWIMP4=vCard,0,_IVCRD,,.VCF,,1,
VIEWEXP1=Comma Separated Value,0,_XCSV,,.CSV,,1,
VIEWEXP2=Lotus 1-2-3,0,_XWKS,,.123,.WK1,.WK3,.WK4,.WKS,.WR1,.WRK,,4,
VIEWEXP3=Structured Text,0,_XSTR,,.CGN,.LTR,.STR,._UNKNOWN,,1,
VIEWEXP4=Tabular Text,1,_XTAB,,.CGN,.LTR,.RPT,.TAB,,1,
VIEWEXP5=vCard 2.1,0,_XVCRD,,.VCF,,1,
VIEWEXP6=vCard 3.0,0,_XVCRD3,,.VCF,,1,
EDITIMP1=ASCII Text,0,_ITEXT,,.C,.H,.PRN,.RIP,.TXT,,1,
EDITIMP2=Binary with Text,0,_ISTRNGS,,.*,,1,
EDITIMP3=BMP Image,0,_IBMP,,.BMP,,18,
EDITIMP4=CGM Image,0,_IFL,,.CGM,.GMF,,8,
EDITIMP5=GIF Image,0,_IGIF,,.GIF,,18,
EDITIMP6=HTML File,0,_IHTML,,.HTM,.HTML,,1,
EDITIMP7=JPEG Image,0,_IJPEG,,.JPG,.JPEG,,18,
EDITIMP8=Lotus 1-2-3,0,_IW4W,_IWKSE,.123,.WK1,.WK3,.WK4,.WKS,.WR1,.WRK,,4,
EDITIMP9=Lotus PIC,0,_IPIC,,.PIC,,8,
EDITIMP10=Lotus Word Pro,0,_IW4W,,.LWP,,2,
EDITIMP11=Microsoft Excel,0,_IW4W,,.XLS,,4,
EDITIMP12=Microsoft RTF,0,_IRTF,_IW4W,.RTF,,2,
EDITIMP13=Microsoft Word,0,_IW4W,,.DOC,,2,
EDITIMP14=PCX Image,0,_IPCX,,.PCX,,18,
EDITIMP15=TIFF 5.0 Image,0,_ITIFF,,.TIF,,18,
EDITIMP16=WordPerfect,0,_IW4W,,.WPD,.WPT,,2,
EDITIMP17=Unsupported File as Text,0,_ITEXT,,.*,._UNKNOWN,,1,
EDITEXP1=ASCII Text,2,_XTEXT,,.C,.H,.PRN,.RIP,.TXT,._UNKNOWN,,1,
EDITEXP2=CGM Image,2,_XCGM,,.CGM,.GMF,,8,
EDITEXP3=Microsoft RTF,2,_XRTF,,.DOC,.RTF,,4,
EDITEXP4=TIFF 5.0 Image,2,_XTIFF,,.TIF,,18,
EDITEXP5=vCard 2.1,0,_XVCRD,,.VCF,,1,
EDITEXP6=vCard 3.0,0,_XVCRD3,,.VCF,,1,
DDETimeout=10
NAMEDSTYLE0=030042617369630000000000000000000000000000000000000000000000000000000000000001010100000A0000000000000100A0050A0000006400A0050A0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009404000000000000
NAMEDSTYLE0_FACE=Default Sans Serif
NAMEDSTYLE1=030042756C6C657400000000000000000000000000000000000000000000000000000000000001010100000A000000000000000008070A000000640008070A0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000049404000000000000
NAMEDSTYLE1_FACE=Default Sans Serif
NAMEDSTYLE2=0300486561646C696E6500000000000000000000000000000000000000000000000000000000010101010B0C0000000000000100A0050A0000006400A0050A0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009404000000000000
NAMEDSTYLE2_FACE=Default Sans Serif
DefaultMailTemplate=mail7.ntf
TCPIP=TCP, 0, 15, 0,,12320
LAN0=NETBIOS,0,15,0,,12288,
COM1=XPC,1,15,0,,12288,
COM2=XPC,2,15,0,,12288,
COM3=XPC,3,15,0,
COM4=XPC,4,15,0,
COM5=XPC,5,15,0,
Ports=TCPIP
DisabledPorts=LAN0,COM1,COM2,COM3,COM4,COM5
KeyFilename=P:\NOTESID\alanparmstrong.id
CertificateExpChecked=P:\NOTESID\alanparmstrong.id 13/05/2009
FileDlgDirectory=C:\Documents and Settings\alan.p.armstrong\Desktop
MailFile=mail\CORPRES\alanparmstrong.nsf
CSEnblRstTm=0
MIMEPromptMultilingual=1
DeskIconColors=0
BackgroundPrinting=1
StickyColumnSort=1
NewMailInterval=5
MIMEMultilingualMode=2
MIMETmpMultilingual=3
MailServer=CN=DCC-MAIL3/O=Dorset County Council
RequestCertTableUpdate=P:\NOTESID\alanparmstrong.id 13/05/2009
WCT_IM_USE_LOOKUP=0
EnableJavaScript=1
DefaultBrowser=0
UseWebPalette=1
ShowAccelerators=1
MIMEConvertWarning=0
URLBarInlineAutoComplete=1
ReplDefFullText=1
ReplDefReplImmed=1
$MIMESaveFormat=2
TemplateSetup=700200
Setup=700200
Location=Office (Network),A02,CN=Alan P Armstrong/OU=ITSERVICES/O=Dorset County Council
ECLSetup=3
DYNINFOCR_OF6DBD3DE4:FDF02172-ONC0C94DF2:DD2B5A86=OF5AFCCF5E:359BBA01-ON21BEF129:871EF723
MailUpgradeCheckTime=29C551
MailSetup=700200
MailUpgradeFolder=700200
$headlineClientId=346A4333:332BFD90-8025734D:002D4D89
RoamClientPrompts=0
NAMES=names.nsf
LastHistoryPruneTime=13/05/2009 09:08:08
ReplDefFullDocs=1
ReplDefPartDocsLimit=0
ReplDefPartDocsLimitAmt=0
ReplDefPartAtchLimit=0
ReplDefPartAtchLimitAmt=0
ReplDefEncrypt=1
ReplDefEncryptType=2
$headlineDisableHeadlines=0
PromptForLocation=0
EmptyTrash=0
UNICODE_Display=1
AltCalendar=0
QuotePrefix=>
QuoteLineLength=70
EnableActiveXInBrowser=1
EnableJavaScriptErrorDialogs=1
EnableLiveConnect=1
DisableImageDithering=1
WindowSizeKeywords=200 162 880 541
DESKWINDOWSIZE=31 98 1241 695
WINDOWSIZEWIN=23 32 1230 744
MAXIMIZED=1
NewMailSeqNum=29027
NewMailSeqNum8025734D:002C6B7D=29027
ChooseNameDlgColWidths=409,124,124,124,9999,
WindowSizeAmbiguousDialog=173 162 933 541
MigrateSmarticons=0
VIEWIMP5=Calendar File (*.ics),0,_IICAL,,.ICS,,1,
VIEWEXP7=Calendar File (*.ics),0,_XICAL,,.ICS,,1,
BookmarkDesignReplaced=0
$DialogMode=0
$EnableAlarms=1
CalendarTimeSlotStart=420
CalendarTimeSlotEnd=1140
CalendarTimeSlotDuration=60
SelectAddressesDialogSize=342,938,162,480,
NameAddressingDlgLastViewName=0,List by name
ExitNotesPrompt=1
BCASE_SITEMAP_DISPLAY=13
$CallTrackCounter=95
SelectNameDialogSize=387,892,134,452,
WindowSizePickKeywords=438 134 403 307
WindowSizeMoveToFolder=473 162 334 336
PrintPreviewInColor=1
WindowSizeSimpleFolderNew=448 162 383 287
Win32InfoboxPos=528 274
DontCheckDefaultMail=1
$W3LocalFormSave=0
WindowSizeDefaultPrompt4=423 162 434 203
WindowSizeOtherServer=471 162 337 212
WindowSizeBrowse=351 162 322 318
Preference_en=,,,1033,,,,,,,
AUTO_SAVE_USER,Alan P Armstrong/ITSERVICES/Dorset County Council=as_AP Armstrong1.nsf
WindowSizeFolderNew=414 162 451 305
HELPWINDOWSIZEWIN=12 47 1266 899
HELPMAXIMIZED=0
WindowSizeNameSoundexMailing=327 309 656 349
WindowSizeIMBrowseDirDlg=497 242 287 388
IM_ENABLE_SSO=1
WindowSizeIMJoinMeetingDlg=479 384 323 178
BuddyListVisible=0
BuddyListPos=93 77 200 400 
WindowMoreStateSearchAndReplace=0
URLAddress1=http://kbalertz.com/938923/restore-printers-upgrade-Windows-Server-Windows-Server.aspx
IM_ADD_TIMESTAMP=1
IM_USE_CANONICAL_NAME=1
MultiRoomDlgSize=346,933,134,447,
URLAddress2=http://www.bit-tech.net/bits/software/2009/01/16/windows-7-beta-performance/1
WindowSizeIMAwayDlg=510 365 295 216
IM_DYN_GROUP_OPEN_STATE=1
NoShowAttachmentWarning=0
WindowSizeBrowseAlarms=369 162 541 282
URLAddress3=http://www.overclockers.co.uk/showproduct.php?prodid=CA-110-AN
URLAddress4=http://172.18.22.98:8080/TeamStructure/navigator.jsp
URLAddress5=\\a3kssl0j1\p\work\drivers
URLAddress6=http://www.moddb.com/mods/10531/no-limit-mod/downloads/10555/no-limit-mod-soulstorm
URLAddress7=http://forums.relicnews.com/showthread.php?t=185954
WindowSizeACLAddUser=486 162 307 112
SelectNamesDialogSize=214,810,162,509,
SPELL_DLL=ltspln50.dll
SPELL_DIR=g:\notes\data
WindowSizeNewDatabase=445 134 389 427
$CreateBookmarkLastFolder=Favorite Bookmarks
WindowSizeBookmark=453 162 374 302
WindowSizeOpenDoc=366 134 548 290
$outlineServer=DCCMAIL1
URLAddress8=http://forums.filefront.com/dawn-war-dark-crusade-general-discussion/320839-how-increase-unit-cap.html
WindowSizeCalendarEmodal=336 162 608 515
URLAddress9=http://www.ocia.net/reviews/icybox4220/page4.shtml
URLAddress10=http://forums.relicnews.com/archive/index.php/t-38722.html
DYNINFOCR_OFA1FF98F1:74779A54-ON06B32EAB:25F70C7E=OFB198D2D6:3B5FA8BC-ON4FAF83E3:A4558EEC
RoamingUpgrade=0
FINDSTRING0=ricoh
FINDSTRING1=richoh
WindowMoreStateSearch=0
URLAddress11=http://news.bbc.co.uk/1/hi/world/south_asia/7240939.stm
SU_IN_PROGRESS=0
SU_NEXT_UPDATE=14/05/2009 09:08:05
SU_FILE_CLEANUP=C:\DOCUME~1\ALANP~1.ARM\LOCALS~1\Temp\7\smkits
SUT_NEXT_UPDATE=14/05/2009 09:08:05


Al


0

Response Number 10
Name: Valerie (by Garibaldi)
Date: May 13, 2009 at 04:17:51 Pacific
Reply:

Well now Al - now that you've posted the content of your .INI file all is clear.

In your very first post you wrote:

Within the ini file i need to find:

Keyfile: P:\notes\notes.id             -<-------- Note this line.

but all i need is the P:\notes\notes.id.

But now you've posted your .INI file content the actual line is:

KeyFilename=P:\NOTESID\alanparmstrong.id

Based on your first post I delimited using a space whereas it should have been the equals (=) character.

Here's the amended script, I leave you to add the Copy and whatever else you want in the :continue sub:

:: Code begins...
@echo off
cls
setlocal enabledelayedexpansion

for /f "delims=" %%1 in (filename.ini) do (
    set line=%%1 & call :checkit
)

:checkit
if /I "!line:~0,7!"=="Keyfile" (
   for /f "tokens=1-2* delims==" %%2 in ("!line!") do (
   set file=%%3
   goto continue
   ))
   goto :eof

:continue
echo %file%

:: Other coding here...
:: Code ends...

Val.


0

Response Number 11
Name: alana257
Date: May 13, 2009 at 07:12:18 Pacific
Reply:

Hi Val

Thanks for the code, it works wonders, only it doesn't work when I try to run it and set the .ini file location as:

("%USERPROFILE%\application data\Lotus\Notes\notes.ini")

Any Ideas? this is where the ini file will always be held.

Thanks again for the code

Al


0

Response Number 12
Name: Valerie (by Garibaldi)
Date: May 13, 2009 at 16:11:28 Pacific
Reply:

Having a look at that problem - more later, unless someone else advises.

Insert the usebackq option in the first For loop:

for /f "usebackq delims=" %%1 in ("%userprofile%\etc.....") do (

V.


0

Sponsored Link
Ads by Google
Reply to Message Icon

mp3 autorun cd command Using the arrow character...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Exstracting part of a line in a ini file

editing a .ini file with a bat file www.computing.net/answers/programming/editing-a-ini-file-with-a-bat-file/7145.html

Editing .ini file with a batch file www.computing.net/answers/programming/editing-ini-file-with-a-batch-file/12127.html

Batch File To alter a .ini file www.computing.net/answers/programming/batch-file-to-alter-a-ini-file/13910.html