HELP... check if file exists, if not EMAIL

Discussion in 'Scripting' started by madmanhiker, Feb 9, 2006.

  1. madmanhiker

    madmanhiker Guest

    Hello all - I thank you in advance for any help. I am new to wss but I am
    familiar with asp. I have been asked to create a script on a iis box to
    check a directory everyday at 8am for the existance of a file that gets
    uploaded with a datetimestamp in its name. if it doesn't exist, send an
    email. If is DOES exist, do nothing. again, any help is greatly appreciated.
    madmanhiker, Feb 9, 2006
    1. Advertisements

  2. madmanhiker

    Umesh Thakur Guest

    this is a sample script that will traverse through given folder, and will look
    for a file with given search pattern within file, (you can use other
    conditions here to suit your need). If condition is satisfied, script will
    send mail to specified user.

    Set objFSO = CreateObject("Scripting.FileSystemObject")

    Set objFolder = objFSO.GetFolder(strFolder)
    Set colFiles = objFolder.Files
    'Loop through all files in given folder.
    for Each objFile in colFiles
    'put your condition here,
    if instr(1,,"datetime stamp here") <> 0 then
    wscript.echo objFile.Name
    end if

    sub sendMail
    Set objEmail = CreateObject("CDO.Message")
    objEmail.From = ""
    objEmail.To = ""
    objEmail.Subject = "file not found!"
    objEmail.Textbody = "File was not found..."
    end Sub
    Umesh Thakur, Feb 9, 2006
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.