Quantcast
Channel: VBForums - ASP, VB Script
Viewing all articles
Browse latest Browse all 686

How to add object property in vbs

$
0
0
Hi,

Can anyone help me to add "file creation" and "File Modification time" properties in below VBS file.


Code:

Option Explicit

Private Const BIF_RETURNONLYFSDIRS = &H1
Private Const BIF_NONEWFOLDERBUTTON = &H200

Private FSO, TS, oFile, oFolder, MinFileSize, sParentDir, sTextFile

On Error Resume Next

With CreateObject("Shell.Application")
  sParentDir = "e:\data"
  If Err Then WScript.Quit

    MinFileSize = CDbl("524288000")  '<-- 500 MB
    If Err Then WScript.Quit

    sTextFile = "c:\logs"
    If Err Then WScript.Quit

    sTextFile = sTextFile & "\" & "big.csv"
End With
'sParentDir="C:\"
'MinFileSize=524288000
'sTextFile=C:\

Set FSO = CreateObject("Scripting.FileSystemObject")
Set TS = FSO.CreateTextFile(sTextFile, True, True)
If Err Then MsgBox Err.Description, vbCritical, "Error " & Err: WScript.Quit

FindFiles sParentDir

TS.Close
Set TS = Nothing
Set FSO = Nothing

Private Sub FindFiles(ByRef ParentDir)
    On Error Resume Next

    With FSO.GetFolder(ParentDir)
        For Each oFile In .Files
                  If oFile.Size >= MinFileSize Then
                If (oFile.Attributes And 39) = 32 Then
                    TS.WriteLine """" & FormatNumber(oFile.Size / &H100000, 2) & " MB"",""" & oFile.Path & """"
                End If
            End If
        Next

        For Each oFolder In .SubFolders
            FindFiles oFolder.Path
        Next
    End With
End Sub

I;m new to vb script.

Thanks in advance.

Viewing all articles
Browse latest Browse all 686

Trending Articles