Batch file to check if file exists if not send email

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Ris
Posts: 1
Joined: 11 Nov 2015 15:42

Batch file to check if file exists if not send email

#1 Post by Ris » 11 Nov 2015 16:09

Hi,
I need to write a batch script to create a oracle export with timestamp and copy the file to another server but want to make sure it is copied then send an email whether it is successful or not. So I have been able to generate export file as I use a variable for file name but the code to check if the file exists on the other server does not get executed. I would appreciate if someone helps with this. This is a batch file runs nightly. I am totally new to dos programming.
I have something similar to below but if section does to get work:

Code: Select all

dumpfile_xx=full_exp-%date:~4,2%%date:~7,2%%date:~10,4%.dmp
logfile_xx=full_exp-%date:~4,2%%date:~7,2%%date:~10,4%.log

expdp db_name/db_pswd DIRECTORY=DATA_PUMP_DIR dumpfile=%dumpfile_xx% full=y logfile=%logfile_xx%

if exist \\xxx\xxx\%dumpfile_xx% (
    echo file exists
) else (
    echo file doesn't exist
)

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Batch file to check if file exists if not send email

#2 Post by Squashman » 11 Nov 2015 17:45

You need to use the SET command to assign something to an environmental variable.

Post Reply