1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
| Option Explicit
Dim objFSO,objStartFolder,objFolder,LogFile,strResult,ws
Set objFSO = CreateObject("Scripting.FileSystemObject")
objStartFolder = Parcourir_Dossier
Set objFolder = objFSO.GetFolder(objStartFolder)
LogFile = Left(Wscript.ScriptFullName, InstrRev(Wscript.ScriptFullName, ".")) & "txt"
On Error Resume Next
strResult = strResult & objFolder.Path & vbtab & objFolder.DateLastModified & vbcrLf
Call ShowSubfolders(objFolder)
If objFSO.FileExists(LogFile) Then
objFSO.DeleteFile(LogFile)
End If
Call WriteLog(strResult,LogFile)
set ws = CreateObject("wscript.shell")
ws.run "Notepad "& LogFile
'**************************************************************
Sub ShowSubFolders(Folder)
Dim Subfolder
Set Folder = objFSO.GetFolder(Folder)
For Each Subfolder in Folder.SubFolders
strResult = strResult & Subfolder.Path & vbtab & Subfolder.DateLastModified & vbcrLf
Call ShowSubFolders(SubFolder.Path)
Next
Call WriteLog(strResult,LogFile)
End Sub
'**************************************************************
Function GetSize(MyFolder)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder= objFSO.GetFolder(MyFolder)
GetSize = FormatSize(objFolder.Size)
End Function
'*************************************************************************
Function FormatSize(iSize)
Dim aLabel,i
aLabel = Array("bytes", "KB", "MB", "GB", "TB")
For i = 0 to 4
If iSize > 1024 Then
iSize = iSize / 1024
Else
Exit For
End If
Next
FormatSize = Round(iSize,2) & " " & aLabel(i)
End Function
'*************************************************************************
Sub WriteLog(strText,LogFile)
Dim objFSO,ts
Const ForAppending = 8
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set ts = objFSO.OpenTextFile(LogFile,ForAppending,True,-1)
ts.WriteLine strText
ts.Close
End Sub
'*************************************************************************
Function Parcourir_Dossier()
Dim objShell,objFolder,NomDossier
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(0, "Veuillez choisir un dossier pour la recherche ",1,"c:\Programs")
If objFolder Is Nothing Then
Wscript.Quit
End If
NomDossier = objFolder.title
Parcourir_Dossier = objFolder.self.path
end Function
'************************************************************************* |
Partager