Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - DateLastModified

Reply
 
Old 08-17-2009   #1 (permalink)
Anonymous


 
 

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
Old 08-17-2009   #2 (permalink)
Pegasus [MVP]


 
 

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
Reply

Thread Tools



Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46