Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


eval objFile.DateCreated

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,52718
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> eval objFile.DateCreated
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 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
 
 
Post #: 1
 
 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

(in reply to zimbot)
 
 
Post #: 2
 
 RE: eval objFile.DateCreated - 10/17/2007 7:44:11 AM   
  zimbot

 

Posts: 3
Score: 0
Joined: 10/16/2007
Status: offline
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

the code ( rvsd )

dim lstmo,objFSO,objFolder,colFiles,objFile
lstmo=get_yyyy_mm(dateadd("m",-1,date))
set objFSO=createobject("Scripting.FileSystemObject")
'this suppose c:\zk exists
If not objFSO.FolderExists("c:\zk\" & lstmo) Then
   objFSO.CreateFolder("c:\zk\" & lstmo)
End If
'this suppose folder c:\za exists
Set objFolder = objFSO.GetFolder("C:\za")  
Set colFiles = objFolder.Files
For Each objFile in colFiles
   If get_yyyy_mm(objFile.DateCreated) = lstmo Then
       objFSO.moveFile objFile.Path, "C:\zk\" & lstmo & "\"
   End If
Next
set colFiles=nothing
set objFolder=nothing
set objFSO=nothing
function get_yyyy_mm(d)    'd type date
   get_yyyy_mm=year(d) & "-" & right("00" & month(d),2)
end function



(in reply to DiGiTAL.SkReAM)
 
 
Post #: 3
 
 RE: eval objFile.DateCreated - 10/17/2007 8:42:01 AM   
  ebgreen


Posts: 5034
Score: 31
Joined: 7/12/2005
Status: online
it moved the files just fine for me.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to zimbot)
 
 
Post #: 4
 
 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

(in reply to zimbot)
 
 
Post #: 5
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> eval objFile.DateCreated Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts