Thursday, September 27, 2007

VBScript to move files according to date

'Script Start

' Covet - Use this script carefully.


Const OverwriteExisting = True

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(" Your source folder - HERE - full path ")



For Each file In f.Files

if DateDiff("m",file.DateCreated, "09/01/2007") = 0 then 'change date accordingly

FSO.CopyFile file.path , " Destination folder with full path and \ at end - HERE " , OverwriteExisting
file.delete

End if


Next



For Each subf In f.subfolders

For Each file In subf.Files

if DateDiff("m",file.DateCreated, "09/01/2007") = 0 then 'change date accordingly

FSO.CopyFile file.path , " Destination folder with full path and \ at end - HERE " , OverwriteExisting
file.delete
End if


Next

Next

wscript.echo "End"





'Script End



How to execute a VBScript

No comments: