Check File Date??

  • I have a package that drops and recreates a table containng unitvalues for the current date each morning. Does anyone know a good way to check and see if the text file in question contains today's date as possibly part of workflow task? Also, as aprt of that, if it were not today's date, to fail the package, so an e-mail could be sent out to notify me. I'm sure someone has ran across this before. Thanks in advance for any help.

    -Pat

  • try some redirection like

    dir somefile /O > temp.txt

    The /O switch places among other things the date the file was created.

    Now look in the file for your date

    John Zacharkan


    John Zacharkan

  • Hoepfully this will help. See additional info for FileSystemObject on msdn website here http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/fsooriscriptingrun-timereference.asp.

    In the DTS package create an ActiveScipt object on the design sheet.

    Open it and set to VBScript (default anyway) and in the function main do as follows.

    Dim fso, f, CrDt

    Set fso = CreateObject("Scripting.FileSystemObject")

    Set f = fso.GetFile("c:\a.bmp")

    CrDt = f.DateCreated

    'Note if the file is not deleted you can try the modified date instead.

    Then you can copy Now() and return fail or success to the package. See BOL "DTSTaskExecResult" for options.

  • Thanks, guys. Here's what I tried, but I keep getting an error: Object Required: 'f.DateLastModified'

    Here's the code:

    Function Main()

    dim fso

    dim f

    dim v

    set fso = CreateObject("Scripting.FileSystemObject")

    set f = fso.GetFile("C:\Test1.txt")

    set v = f.DateLastModified

    IF DateDiff("d", Now, v) = 0 Then

    Main = DTSStepScriptResult_ExecuteTask

    ELSE

    Main =DTSTaskExecResult_Failure

    End If

    End Function

    Any ideas here?

    Thanks, guys.

  • by the way, thanks for the link and the information, they were very helpful.

  • nevermind, I shouldn't have used set v = f.DateLastModified, just v = ....

    Thanks for your help.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply