Hi, need one help!!

June 1, 2009 at 20:38:11
Specs: Windows XP
Hi buddy, I am Aveen. Let me explain what I in need of?

I need to write a batch file to search whether particular file is exist ina folder using file name format. We have a system which generates some reports daily by 5pm. Just our batch code shout check whether that file is generated? If generated it should send a mail to group we specify and if not present then also it should send mail.

File Name will be like this

LSR_REPORT_ddmmyy

Where ddmmyy is current datetimeyear.

Its really in damn urgent. Could you please reply to my mail ID TheAveen@gmail.com

Your help will be very much appreciable..

Yours
Aveen


See More: Hi, need one help!!

Report •


#1
June 3, 2009 at 01:31:21
If the file[s] are in c:\files, this will list the files with that naming convention.

You need to decide on what basis which email will be sent. Do you have a command line email client?

==========================
@echo off & setLocal EnableDelayedExpansion

pushd c:\files

for /f "tokens=* delims=" %%a in ('dir /b LSR_REPORT*.*') do (
echo %%a
)


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

M2


Report •

#2
June 3, 2009 at 01:42:34
Hi friend, Thanks for the reply.

I sent u private mail explaining the issue in details..

Okay let me explain you again..

We have a system which generates daily report in .xls format 5pm exactly for 20 customers.

Actually the report is generating in Unix system then it transfers to the Windows box.

After transferring to unix box The fine name format will be look like this day_CustName_LSR_YYYYMMDD.xml

LSR is the contant value and YYYYMMDD is the date of creation of file.Actually the yersterday report will get generate today. Mean to say if today is 03/06/2009,

we will have Wed_SBC_LSR_20090602.XML file.

The batch script should check whether the file is created for the date. If no it should send a alert mail SAY, aveen@xyz.com. Actually I am bit new to batch script file and I seen your posts. Could you please help on this.

Waiting for your reply.
Aveen


Report •

#3
June 3, 2009 at 01:47:32
Please gimme the script which fulfils my requirement for 1 cust so that I can run that script indivisually for all customers.

And also I need that script to run automatically at specific time say 5:15PM [Report files are generating by 5PM for all customers] so that It can confirm all report files are generated for all customers.

Regards,
Aveen


Report •

Related Solutions

#4
June 3, 2009 at 01:51:56
This is the OS and DOS version I am using

Microsoft Windows XP [Version 5.1.2600]


Report •

#5
June 3, 2009 at 09:59:14
SETLOCAL ENABLEEXTENSIONS

For /f "tokens=1-7 delims=:/-, " %%i in ('echo exit^|cmd /q /k"prompt $D $T"') do (
For /f "tokens=2-4 delims=/-,() skip=1" %%a in ('echo.^|date') do (
set dow=%%i
set %%a=%%j
set %%b=%%k
set %%c=%%l
set hh=%%m
set min=%%n
set ss=%%o
)
)
set YYMMDD=%yy%%mm%%dd%
set FILENAME=%dow%_SBC_LSR_%YYMMDD%.xml
rem echo %FILENAME%
if not exist %FILENAME% goto MAILNOTIFY


Report •

#6
June 4, 2009 at 00:15:56
Hi Friend,

Thank you very much for your reply.

Your code is just generating the output as I expected. But I have issue in this. Code is just displaying the output on command prompt when I run that.

Actually, it need just to check whether the file is created with the current date. If so no need to prompt any message if no, as you mentioned control should move to MAILNOTIFY

Can you provide the scripts to send the mail to a specific mail ID ??

It will be very helpfull..
Sorry if I borthering U much,

Waiting for your reply..

Aveen


Report •

#7
June 4, 2009 at 00:28:04
Here is the output I am getting!!

F:\qa>a.bat

F:\qa>SETLOCAL ENABLEEXTENSIONS

F:\qa>For /F "tokens=1-7 delims=:/-, " %i in ('echo exit|cmd /q /k"prompt $
') do (
For /F "tokens=2-4 delims=/-,() skip=1" %a in ('echo.|date') do (
set dow=%i
set %a=%j
set %b=%k
set %c=%l
set hh=%m
set min=%n
set ss=%o
)
set FILENAME=_SBC_LSR_.xml
if not exist goto MAILNOTIFY
)

F:\qa>(
For /F "tokens=2-4 delims=/-,() skip=1" %a in ('echo.|date') do (
set dow=Thu
set %a=06
set %b=04
set %c=2009
set hh=12
set min=55
set ss=44.62
)
set FILENAME=_SBC_LSR_.xml
if not exist goto MAILNOTIFY
)

F:\qa>(
set dow=Thu
set mm=06
set dd=04
set yy=2009
set hh=12
set min=55
set ss=44.62
)
'MAILNOTIFY' is not recognized as an internal or external command,
operable program or batch file.
F:\qa>


Could you please help me? Whatever the things are displaying here hsould calculate internally and if the file is not generated with todays date then the control should send an e-mail to a specifid mail ID.

If this works fine it will be very helpfull for me.

Waiting for your reply.

Aveen


Report •

#8
June 4, 2009 at 19:03:56
Hi Buddy, you der?

I am waiting for your reply...

If you need more information please let me know.

Regards,
Aveen


Report •

#9
June 4, 2009 at 20:40:58
On windows, you can use the tool "blat" to send mail

http://www.blat.net/

see the docs here:

http://www.blat.net/syntax/syntax.html

I left MAILNOTIFY in there as a stub for you to handle mail as you chose.


Report •

#10
June 4, 2009 at 20:55:57
But the code is displaying the search result in screen. I just want those calculation should handle in background. Only if file not present it should send mail. I posted you the output what I am getting when I run the code. Please have a look on that. Once I run it is displaying program, each and everyoutputs.

Report •

#11
June 7, 2009 at 22:01:12
Hi Friend, I am looking forward for your reply.

Could you please gimme the update scripts? The script what you have mentioned before displays the outout on screen.

But, the script should check whether the file with current date is present in the folder. If no it should mail that the desired file is not present. Could you please help on this?

Yours
Aveen


Report •


Ask Question