Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

File parsing and for loop

Original Message
Name: ajay
Date: September 5, 2007 at 08:16:45 Pacific
Subject: File parsing and for loop
OS: win2k + sp4
CPU/Ram: 128KB
Comment:
I have written a batch script but not getting desired output.
Following is the script:
*********************
@echo off
setlocal
For /f "tokens=1,2,3,4,5 delims= " %%a in (data.txt) Do (
If "%%b"=="MS_TYPE" -------------------
If "%%b"=="MS_TYPE" Echo Module Type %%c
for /f "tokens=4,5,6,7,8,9 delims=,> " %%i in (version.txt) do (
If "%%i"=="%%c" Echo Module Version: %%n
)
If "%%b"=="MS_TYPE" Echo Module-Name: %%a
If "%%b"=="DEFAULT_VAL" Echo Default value is: %%c
)
endlocal
**********************
file data.txt -
my_db1 MS_TYPE Online
my_db1 DEFAULT_VAL Y
my_db1 DESCRIPTION sam_des1
my_db1 INTERVAL 30
my_db1 MS_TYPE Online
my_db1 DEFAULT_VAL Y
my_db1 DESCRIPTION sam_des12
my_db1 INTERVAL 40
my_db1 MS_TYPE Online
my_db1 DEFAULT_VAL Y
my_db1 DESCRIPTION sam_des14
my_db1 INTERVAL 60
my_db2 MS_TYPE LocalSystem
my_db2 DEFAULT_VAL N
my_db2 DESCRIPTION sam_des2
my_db2 INTERVAL 10
file version.txt -
For Module <my_db1 Online>, version of Module is 4.0.0

For Module <local LocalSystem>, version of Module is 5.0.00

For Module <my_db2 Online>, version of Module is 4.0.0
For Module <my_db3 Online>, version of Module is 4.0.0

I need the data version vise.
I need following output:-
Module Type Online
Module Version: 4.0.0
Module-Name: my_db1
Default value is: Y
--------------
Module-Name: my_db2
Default value is: Y
-------------
Module Type Online
Module-Name: my_db3
Default value is: Y
------------------
Module Type LocalSystem
Module Version: 5.0.00
Module-Name: local
Default value is: N
I am working on it for 3-4 days but couldn't fix it. If anyone helps, it will be really great.

Thanks!


ajay


Report Offensive Message For Removal


Response Number 1
Name: ajay
Date: September 5, 2007 at 22:01:47 Pacific
Subject: File parsing and for loop
Reply: (edit)
In the previous message please change desired output:
.......
[Module Type Online] remove this line
Module-Name: my_db3
......
by mistake I had written that. Actually what I need is version and module type should be printed once and then all modules under that version/type.

ajay


Report Offensive Follow Up For Removal




Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: File parsing and for loop

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




Batch File- Current Date in Excel

how to setup call of duty to joytok

WindowsME / HotMail Problem

Corrupt memory

Convert fat32 to Ntfs


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC