A
Anonymous
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!
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!