Friends,
I have some code that I am struggling with..
my goal is to make a dir named 2007-10
and then move files that were created in the month of october in there.
I am very close ... I can make the dir
but I am having trouble with the evaluation
here is my code::::::::::::::
' :~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:
' :~:~:~: script to tidy up ip_knox - js 10,07 ~:~:~:~:
' :~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:
'
' makes a dir yyyy-mm :: Of Last Month , so if today is Oct it makes 9 , 2007-9
'
If not CreateObject("Scripting.FileSystemObject").FolderExists(Year(Date) & "-" & (Month(Date))-1) Then CreateObject("Scripting.FileSystemObject").CreateFolder(Year(Date) & "-" & (Month(Date))-1) End If
lstmo = (Year(Date) & "-" & (Month(Date))-1)
WScript.Echo "1st lst mo is " & lstmo
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.MoveFolder "C:\z\"& lstmo , "c:\zk\" & lstmo
WScript.Echo "this month is " & Month(Date)-0
''''
'''' now lets move some files
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\za") ' ''****> this would be d:\ip_knox good mov 4 ever
Set colFiles = objFolder.Files
'lstmo2 = DateAdd("m", -0, Now)
lstmo2 = (Year(Date) & "-" & (Month(Date))-0)
'WScript.Echo " 2nd lstmo is " & lstmo
'WScript.Echo " lstmo2 is " & lstmo2
For Each objFile in colFiles
'''''' here is the part that I cannot seem to get
''''''' as you can see I have tried a few things
'If objFile.DateCreated < lstmo2 Then
' If objFile.DateCreated < Now Then
'If objFile.DateCreated < DateAdd("m", -0, Now) Then
If objFile.DateCreated = Month(Date)-1 Then
'If DateDiff("d", objFile.DateCreated, Now) > 30 then
'WScript.Echo "I was made " & objFile.DateCreated
'WScript.Echo "comparing " & DateAdd("m", -0, Now)
'WScript.Echo "last month is " & Month(Date)-1
WScript.Echo "last month is " & DateAdd("m", -0, Now)
objFSO.copyFile objFile.Path, "C:\zk\" & lstmo & "\"
WScript.Echo "the path is " & objFile.Path
End If
Next
''''''''''''''''''''''''''''''''''''''''''''''''''''''
thanks in advance
I have some code that I am struggling with..
my goal is to make a dir named 2007-10
and then move files that were created in the month of october in there.
I am very close ... I can make the dir
but I am having trouble with the evaluation
here is my code::::::::::::::
' :~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:
' :~:~:~: script to tidy up ip_knox - js 10,07 ~:~:~:~:
' :~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:
'
' makes a dir yyyy-mm :: Of Last Month , so if today is Oct it makes 9 , 2007-9
'
If not CreateObject("Scripting.FileSystemObject").FolderExists(Year(Date) & "-" & (Month(Date))-1) Then CreateObject("Scripting.FileSystemObject").CreateFolder(Year(Date) & "-" & (Month(Date))-1) End If
lstmo = (Year(Date) & "-" & (Month(Date))-1)
WScript.Echo "1st lst mo is " & lstmo
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.MoveFolder "C:\z\"& lstmo , "c:\zk\" & lstmo
WScript.Echo "this month is " & Month(Date)-0
''''
'''' now lets move some files
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\za") ' ''****> this would be d:\ip_knox good mov 4 ever
Set colFiles = objFolder.Files
'lstmo2 = DateAdd("m", -0, Now)
lstmo2 = (Year(Date) & "-" & (Month(Date))-0)
'WScript.Echo " 2nd lstmo is " & lstmo
'WScript.Echo " lstmo2 is " & lstmo2
For Each objFile in colFiles
'''''' here is the part that I cannot seem to get
''''''' as you can see I have tried a few things
'If objFile.DateCreated < lstmo2 Then
' If objFile.DateCreated < Now Then
'If objFile.DateCreated < DateAdd("m", -0, Now) Then
If objFile.DateCreated = Month(Date)-1 Then
'If DateDiff("d", objFile.DateCreated, Now) > 30 then
'WScript.Echo "I was made " & objFile.DateCreated
'WScript.Echo "comparing " & DateAdd("m", -0, Now)
'WScript.Echo "last month is " & Month(Date)-1
WScript.Echo "last month is " & DateAdd("m", -0, Now)
objFSO.copyFile objFile.Path, "C:\zk\" & lstmo & "\"
WScript.Echo "the path is " & objFile.Path
End If
Next
''''''''''''''''''''''''''''''''''''''''''''''''''''''
thanks in advance