Login | |
|
 |
eval objFile.DateCreated - 10/16/2007 5:38:50 AM
|
|
 |
|
| |
zimbot
Posts: 3
Score: 0
Joined: 10/16/2007
Status: offline
|
Friends, I have been struggling with some code ... i wish to create a dir called 2007-10 and then move into there files that were created in october. so my from is the dir called c:\za , and to to is C:\zk\2007-10 ( this whole za , zk is just for testing...) i have much of it working.. My problem is the evaluating of objFile.DateCreated and making certain that it was in Oct. 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 ''''''''''''''''''''''' As you can see here is where my problem is : note the many attempts ''''''''''''''''''''''''' I am sota stumped '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
|
|
| |
|
|
|
 |
RE: eval objFile.DateCreated - 10/16/2007 7:46:15 AM
|
|
 |
|
| |
DiGiTAL.SkReAM
Posts: 1184
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
|
WScript.Echo MonthName(Month(DateValue(oFSO.GetFile("c:\test.txt").DateCreated))) WScript.Echo Month(DateValue(oFSO.GetFile("c:\test.txt").DateCreated)) In my own opinion, the best site for researching Date/Time functions for vbs is http://www.pctools.com/guides/scripting/id/2/?act=reference
< Message edited by DiGiTAL.SkReAM -- 10/16/2007 7:47:34 AM >
_____________________________
"Would you like to touch my monkey?" - Dieter (Mike Meyers) "It is better to die like a tiger, than to live like a pussy." -Master Wong, from Balls of Fury
|
|
| |
|
|
|
 |
RE: eval objFile.DateCreated - 10/17/2007 10:56:26 AM
|
|
 |
|
| |
DiGiTAL.SkReAM
Posts: 1184
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
|
quote:
ORIGINAL: zimbot hmmmm - ok maybe I wasn't clear - i do feel confused.. What I am asking for help with is why do my files in c:\za that were created in september not get moved to c:\zk\2007-09 the dir 2007-09 IS being made quote:
ORIGINAL: zimbot My problem is the evaluating of objFile.DateCreated and making certain that it was in Oct. Sorry, but reading your first post, you seemed to be having difficulty determining the month from the datecreated. What errors are you getting now?
_____________________________
"Would you like to touch my monkey?" - Dieter (Mike Meyers) "It is better to die like a tiger, than to live like a pussy." -Master Wong, from Balls of Fury
|
|
| |
|
|
|
|
|