Windows Vista Forums

DateLastModified
  1. #1


    Anonymous Guest

    DateLastModified

    The following script is a small piece of a larger script. I am trying to
    move all text files that begin with "BA" and are older than today to a
    different folder. The script does not give me any erros. The issue is that
    is still moves all the files that begin with "BA" regardless of the date
    modified.

    3 files named:

    BA20090815.txt
    BA20090816.txt
    BA20090817.txt

    Only files BA20090815.txt and BA20090816.txt should be moved but all 3 files
    are being moved.

    If I put in the code wsh.echo objFile.DateLastModified the correct 2 files
    appear. Here is the code:

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set objfolder = fso.getfolder("c:\document\BLMed")
    For Each objFile in objFolder.Files
    If Left(objFile.Name, 2) = "BA" Then
    If DateDiff("d", objFile.DateLastModified, Now) > 1 Then
    fso.MoveFile "c:\document\BLMed\BA*.txt", "c:\document\BLMed\Logs\"
    'wsh.echo objFile.DateLastModified
    End If
    End If
    Next



    I do not want to use a bat or cmd file or robocopy because this is a small
    piece of a bigger script. The rest of the script works except this one piece.

    Thanks!


      My System SpecsSystem Spec

  2. #2


    Pegasus [MVP] Guest

    Re: DateLastModified

    See the post that New Anon crossposted for you.

    "Anonymous" <Anonymous@xxxxxx> wrote in message
    news:820E484E-A752-4ECF-8B1F-8D27F1B6782B@xxxxxx



      My System SpecsSystem Spec

DateLastModified problems?