Dacă aveți nevoie să scoateți rapid un raport în care să existe conținutul unui folder, puteți folosi VB Script. Următorul cod va genera un fișier .csv. Se poate folosi Microsoft Excel pentru deschidere.
Pentru departajarea coloanelor, datorită setărilor locale se va putea folosi alternativ "," sau ";".
If you need to quickly extract a report with a certain folder contents, you may use VB Script. The following code will generate a .csv file. You may use Microsoft Excel to open it.
For the separation of the columns, due to the local settings it will be possible to use alternatively "," or ";".
'source: https://code-for-vb.blogspot.com/2019/11/the-folder-contents-vb-script.html
'please to mention
Dim Fol
Dim sFol
Dim Fil
Dim strPath
Dim fso
Dim objShell
Dim MyFile
Dim CurrentDirectory
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Set fso = CreateObject("Scripting.FileSystemObject")
CurrentDirectory = fso.GetAbsolutePathName(".")
Set objShell=CreateObject("WScript.Shell")
strPath = InputBox("Input the folder address:")
On Error Resume Next
Set Fol = fso.GetFolder(strPath)
If Err.Number <> 0 Then
Eroare()
WScript.Quit
End if
On Error GoTo 0
If fso.FileExists(CurrentDirectory & "\txtStructList.csv") Then fso.DeleteFile(CurrentDirectory & "\txtStructList.csv")
Set MyFile = fso.OpenTextFile(CurrentDirectory & "\txtStructList.csv", ForAppending, True, TristateUseDefault)
MyFile.WriteLine "Name , Type , Date created , Date modified , Date accessed , Files number , Subfolders number , Size"
For Each sFol In Fol.SubFolders
MyFile.WriteLine sFol.Name & " , folder , " & sFol.DateCreated & " , " & sFol.DateLastModified & " , " & sFol.DateLastAccessed & " , " & sFol.Files.Count & " , " & sFol.SubFolders.Count & " , " & sFol.Size & " bytes"
Next
For Each Fil In Fol.Files
MyFile.WriteLine Fil.Name & " , fisier , " & Fil.DateCreated & " , " & Fil.DateLastModified & " , " & Fil.DateLastAccessed & " , , , " & Fil.Size & " bytes"
Next
MyFile.Close
objShell.Run CurrentDirectory & "\txtStructList.csv"
Sub Eroare()
MsgBox Err.Description, vbExclamation, "ERR: " & Err.Number
End Sub
Niciun comentariu:
Trimiteți un comentariu