Searching for file in folder named as current month using vbs script

Home Forums Scripting General Scripting Searching for file in folder named as current month using vbs script

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    igor7
    Member
    #149529
    Hi, all!!
    I need some help with vbs script. We have production environment where log file is updated each day in folder named as current month.
    (\serveryearcurrent month).
    For example: \London2010juneLogFile.cvs
    I created script that can take log file from the current folder (June for now) and email it to few recipients. Here is the script code:

    [LEFT][COLOR=#555a5f][FONT=Verdana]Set objMessage = CreateObject(“CDO.Message”) [/FONT][/COLOR]
    [FONT=Verdana][COLOR=#555a5f]objMessage.Subject = “Orion Heater Tracking file” [/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]objMessage.From = “[email protected]” [/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]objMessage.To = “[email protected], [email protected]” [/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]objMessage.TextBody = “Orion Heater Tracking file attached to this e-mail message.”[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]objMessage.AddAttachment “\London2010juneLogFile.cvs”[/COLOR][/FONT][/LEFT]

    [LEFT][COLOR=#555a5f][FONT=Verdana]objMessage.Configuration.Fields.Item _[/FONT][/COLOR]
    [FONT=Verdana][COLOR=#555a5f](“http://schemas.microsoft.com/cdo/configuration/sendusing”) = 2 [/COLOR][/FONT][/LEFT]

    [LEFT][FONT=Verdana][COLOR=#555a5f]objMessage.Configuration.Fields.Item _[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f](“http://schemas.microsoft.com/cdo/configuration/smtpserver”) = “smtp.myserver.com”[/COLOR][/FONT][/LEFT]

    [LEFT][FONT=Verdana][COLOR=#555a5f]objMessage.Configuration.Fields.Item _[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f](“http://schemas.microsoft.com/cdo/configuration/smtpserverport”) = 25 [/COLOR][/FONT][/LEFT]

    [LEFT][COLOR=#555a5f][FONT=Verdana]objMessage.Configuration.Fields.Update[/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana]objMessage.Send[/FONT][/COLOR][/LEFT]

    [LEFT][COLOR=#555a5f][FONT=Verdana]WScript.Echo “The email message has been sent!!”[/FONT][/COLOR][/LEFT]
    [/CODE]

    [LEFT][COLOR=#555a5f][FONT=Arial]The main problem is: next month the log file will be in folder named July ( [URL=”file://\London2010JulyLogFile.cvs”]\London2010JulyLogFile.cvs[/URL]) and the path in the script will need to be changed accordingly… It is possible to use some variable based on current month to tell the script where look for the log file to avoid situation when user will need change path in the script each month manually?[/FONT][/COLOR][/LEFT][CODE]

    Set objMessage = CreateObject(“CDO.Message”)
    objMessage.Subject = “Orion Heater Tracking file”
    objMessage.From = “[email protected]
    objMessage.To = “[email protected], [email protected]
    objMessage.TextBody = “Orion Heater Tracking file attached to this e-mail message.”
    objMessage.AddAttachment “\London2010juneLogFile.cvs”
    objMessage.Configuration.Fields.Item _
    (“http://schemas.microsoft.com/cdo/configuration/sendusing”) = 2
    objMessage.Configuration.Fields.Item _
    (“http://schemas.microsoft.com/cdo/configuration/smtpserver”) = “smtp.myserver.com”
    objMessage.Configuration.Fields.Item _
    (“http://schemas.microsoft.com/cdo/configuration/smtpserverport”) = 25
    objMessage.Configuration.Fields.Update
    objMessage.Send
    WScript.Echo “The email message has been sent!!”

    [/CODE]

    The main problem is: next month the log file will be in folder named July ( [URL=”file://\London2010JulyLogFile.cvs”]\London2010JulyLogFile.cvs[/URL]) and the path in the script will need to be changed accordingly… It is possible to use some variable based on current month to tell the script where look for the log file to avoid situation when user will need change path in the script each month manually?
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.