Computing.Net > Forums > Windows XP > Urgent Help - Windows Batch Script Required

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.

Urgent Help - Windows Batch Script Required

Reply to Message Icon

Name: Manohar
Date: September 14, 2009 at 05:22:43 Pacific
OS: Windows XP
Product: Dos / Dos
Subcategory: General
Comment:

Basically my batch script has to do a line count of a file (.txt) and append the value of the result to the end of the following (in parameter file):

I have a parameter file with following contents:
Filename is manohar.prm
Contents are as follows:

[WCPIT_BIO_EDW.WF:w_DDDMD_LNDG_IMS_NONRET_SALES]
$$Cust_RowCount=72648
$$Sales_RowCount=5235998
$$OuletChangeLog_RowCount=931
$$DRM45_RowCount=581
$$Control_RowCount=4495
$$Outl_Subcat_RowCount=100
$$Fac_Subcat_RowCount=149 that has to be updated with rowcounts of a file (Test.txt) at the end of the variables as shown - please help....



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: September 14, 2009 at 05:54:57 Pacific
Reply:

@echo off & setlocal > manohar.tmp
for /F %%j in ('type "Test.txt" ^| find /C /V ""') do set rowcnt=%%j
for /F "tokens=1-2 delims==" %%j in (manohar.prm) do (
  if "%%j"=="$$Fac_Subcat_RowCount" (
    echo.%%j=%rowcnt%
  ) else (
    if "%%k"=="" (echo.%%j) else (echo.%%j=%%k)
  )
) >> manohar.tmp

The updated file is manohar.tmp; if correct delete the original one and rename.


1

Response Number 2
Name: Manohar
Date: September 14, 2009 at 06:22:38 Pacific
Reply:

Thank You Very Much IVO.....
Its really helping me a lot.

Well I have few more clarifications required:
a) The record count value is present in a file (rec_cnt.txt) that has a single line in it that contains TRAIL0101 000000000007.
In the above statement TRAIL0101 is repeated value and 000000000007 is the row count, for example the row count is 30 then the value changes to 000000000030.
b) We are suppose to fetch the row count value from rec_cnt.txt ignoring the zeroes and add this value to the parameter file ------->
Now in the parameter file we have many lines - thus we need to search for the line that has a specific phrase like "w_DDDMD_LNDG_IMS_NONRET_SALES" as shown below and then update the count fetched after the '=' sign of $$DRM45_RowCount:-
[WCPIT_BIO_EDW.WF:w_DDDMD_LNDG_IMS_NONRET_SALES]
$$DRM45_RowCount = value that is been fetched.

The requirement is too much - but I need some help.....



0

Response Number 3
Name: IVO
Date: September 14, 2009 at 08:01:18 Pacific
Reply:

@echo off & setlocal EnableDelayedExpansion> manohar.tmp
set /P rowcnt=< rec_cnt.txt
set rowcnt=%rowcnt:* =%
for /L %%j in (0,1,80) do if not "!rowcnt:~%%j,1!"=="0" (
  set rowcnt=!rowcnt:~%%j!
  goto :DONE
)
:DONE
for /F "tokens=1-2 delims==" %%j in (manohar.prm) do (
  if "%%j"=="$$DRM45_RowCount" (
    echo.%%j=%rowcnt%
  ) else (
    if "%%k"=="" (echo.%%j) else (echo.%%j=%%k)
  )
) >> manohar.tmp


1

Response Number 4
Name: Manohar
Date: September 14, 2009 at 20:33:37 Pacific
Reply:

IVO thanks a lot for your help.....
The code is working perfectly except for a small bug in it which i have explained below:

The file that has the count details (rec_cnt.txt) contains: the information as shown below:
HEADER0101IMS HEALTHXpo Weekly NEW.PROD.RW9305D.WK0933.LINK019.SRCESUPP W2009080210120090831132102ssnyder@us.imshealth.com
TRAIL0101 000000001016 0000000000CKSUM000002819980261
The above text is in a single line in the rec_cnt.txt.

Issue/Bug:
---------------
The manohar.prm file that has the following content:
[WCPIT_BIO_EDW.WF:w_DDDMD_LNDG_IMS_NONRET_SALES]
$$Cust_RowCount=72648
$$Sales_RowCount=5235998
$$OuletChangeLog_RowCount=931
$$DRM45_RowCount=HEALTHXpo Weekly NEW.PROD.RW9305D.WK0933.LINK019.SRCESUPP W2009080210120090831132102ssnyder@us.imshealth.com
$$Control_RowCount=4495
$$Outl_Subcat_RowCount=100
$$Fac_Subcat_RowCount=149
IN the above file content the text in bold is been fetched from the rec_cnt.txt file and been pasted after "$$DRM45_RowCount".
Instead the code has to fetch only the record count details which is part of the text TRAIL0101 000000000007 where 7 is the actual count - so ideally it should something be like this.........
$$DRM45_RowCount = 7

Thanks again - I am sure I nearing to the requirement.


1

Response Number 5
Name: Manohar
Date: September 15, 2009 at 06:02:05 Pacific
Reply:

Hi IVO,

Would also like to know how to have the batch file executed from Informatica 8.6 to implement the same.
Thanks and regards
Manohar Rao


0

Related Posts

See More



Response Number 6
Name: IVO
Date: September 15, 2009 at 09:19:53 Pacific
Reply:

Are you sure the text the line count is catched from is contained in ONE line?

From your post and the behavior of my script it seems the lines are two, the first beginning with HEADER and the other with TRAILER.

What is Informatica 8.6? I'm italian but never heard such application ( by the way Informatica is the Italian word for Information Technology).


0

Response Number 7
Name: Manohar
Date: September 15, 2009 at 20:28:37 Pacific
Reply:

Thanks for your response IVO.....
Wonderful - you question is perfect but I apologies for providing you an incorrect information. As the HEADER file is in *.001 format I used Notepad to open it which pulled the contents in a single line. Where as when I open the same HEADER file using Wordpad it is in two lines as you said - the first beginning with HEADER and the other with TRAILER.

Well the answer for the other question is:
Informatica is a data integration platform, some of the key characteristics of Informatica that stand out are the
1. ETL (Data Extraction, Transformation and Load) process components and the user interface
2. Metadata Management
3. Wider/Huge amount of data handling.


In addition to the above I have posted another requirement in the same forum:
http://www.computing.net/answers/wi...

Please assist.


1

Response Number 8
Name: IVO
Date: September 16, 2009 at 02:36:03 Pacific
Reply:

In the script in Post #3 replace

set /P rowcnt=< rec_cnt.txt
set rowcnt=%rowcnt:* =%

with

for /F "tokens=2" %%j in (rec_cnt.txt) do set rowcnt=%%j

About Informatica 8.6 I can't help as I do not have any exposure to that environment.

About your question regarding unzipping the .gz archives the script is quite easy to code but it depends on the tool used to unzip as there is a lot on the web either commercial or free and each one has different command line parameters.

Take the advice posted: these questions are better handled in the Programming Forum..


1

Response Number 9
Name: Manohar
Date: September 16, 2009 at 02:43:08 Pacific
Reply:

Fantastic - IVO
Not sure how to thank you.....?

The code is perfect and is just listening to my words now.....
Will revert if I need any clarification.
Do you have any specific email address where I can communicate if I am not able to reach you through this forum?

Thanks Again!
:-)


1

Response Number 10
Name: IVO
Date: September 16, 2009 at 03:31:22 Pacific
Reply:

I'll send you a private message with my e-mail address.


1

Response Number 11
Name: Manohar
Date: September 16, 2009 at 05:43:35 Pacific
Reply:

Hi IVO,

Thanks for your message, in addition to the above requirement there is a small additional task that has to be considered.
The for loop that we have used:
for /F "tokens=2" %%j in (Count.001.head) do set rowcnt=%%j
fetches the row count details from the file Count.001.head, but can we have it modified to search a part of the file name string and consider the file that ends with 0001.head.
For example:
The actual file that has the row count is something like:
NEW.PROD.RW92452.CLI561.WK0933.SUMCOMMA.001.head
The only part that remains unchanged in the above file name is 'SUMCOMMA', so my script has to look into a folder named 'SRC_FILES' that has SUMCOMMA word as a part of the filename with extension 001.head

Ooooof I am really wonder or cannot imagine to have to code such a requirement without your help....
:-)
Thanks and regards
Mano


1

Response Number 12
Name: IVO
Date: September 16, 2009 at 06:47:20 Pacific
Reply:

for %%k in (*SUMCOMMA.001.head) do (
   for /F "tokens=2" %%j in (%%k) do set rowcnt=%%j
)

Use the mail address I sent as this thread is dying.


1

Sponsored Link
Ads by Google
Reply to Message Icon

Crystal Report design wit... Endless Beep if any mic i...


Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Urgent Help - Windows Batch Script Required

Batch Script for finding the files www.computing.net/answers/windows-xp/batch-script-for-finding-the-files/169765.html

I need urgent help plz www.computing.net/answers/windows-xp/i-need-urgent-help-plz/172544.html

Batch file for removing dupes www.computing.net/answers/windows-xp/batch-file-for-removing-dupes/179346.html