Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Object Property Question

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Object Property Question
  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 >>
 Object Property Question - 7/7/2008 7:00:24 AM   
  bionicjoe

 

Posts: 1
Score: 0
Joined: 7/7/2008
Status: offline
Hey all.

I've pretty much copy and pasted the following script together which is intended to recurse through a directory deleting old .gz files based on CreationDate.

However I get an error stating that the object doesn't support that property, but I know that is a valid prop. What am I missing?


'Get the date, subtract 180 days, convert to YYYYMMDD format
dtmDate = Date - 180
strDay = Day(dtmDate)
If Len(strDay) < 2 Then
   strDay = "0" & strDay
End If
strMonth = Month(dtmDate)
If Len(strMonth) < 2 Then
   strMonth = "0" & strMonth
End If
strYear = Year(dtmDate)
strTargetDate = strYear & strMonth & strDay

CleanUp "E:\MonitorArchive\Archive"

Sub CleanUp(strFolderPath)
Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(strFolderPath) Then
DeleteContent objFSO, strFolderPath
End If
End Sub

Sub DeleteContent(objFSO, strFolderPath)
Dim objFolder : Set objFolder = objFSO.GetFolder(strFolderPath)
Dim objFile
Dim strDate
For Each objFile In objFolder.Files

   strDate = Left(objFile.CreationDate, 8)    ' <--- Error Line

   If strDate < strTargetDate Then
       If objFile.Extension = "gz" Then
           objFile.Delete True
       End If
   End If
Next

Dim objSubFolder
For Each objSubFolder In objFolder.SubFolders
DeleteContent objFSO, objSubFolder.Path
objSubFolder.Delete True
Next
End Sub


_____________________________

Hating weezer is like hating freedom.
 
 
Post #: 1
 
 RE: Object Property Question - 7/7/2008 7:05:03 AM   
  dm_4ever


Posts: 2664
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
It's actually DateCreated not CreationDate

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to bionicjoe)
 
 
Post #: 2
 
 RE: Object Property Question - 7/7/2008 7:05:14 AM   
  ebgreen


Posts: 5041
Score: 31
Joined: 7/12/2005
Status: offline
The File object does not support the CreationDate property. Instead use the DateCreated property.

_____________________________

"... 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 bionicjoe)
 
 
Post #: 3
 
 
 
  

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 >> Object Property Question 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