Hello guys,
Not-even-close-to-expert to scripting, i've been in charge to develop a script, only in VBS or batch file, that can do the following:
- Search a list of pre-determined computers and specific path (example: \\computer\c:\<random folder>\<random folder> for only *.pst files, if not, returns an information saying that it doesnt have any file present.
- Export that list to excel by date created, date last modified, size, attributes and path
I've search and compiled a vbs that does something like what i want, but it extracts all the files except the specific file i want and it lacks the string/syntax to point for the list of computers and their specific path.
Here's the VBS i've managed to compile:
==========================================================
Dim strFolder, objFSO, objFolder
Dim strExcelPath, objExcel, objSheet, intRow
Const xlExcel7 = 39
' Specify main folder.
strFolder = "C:\Program Files"
' Retrieve folder object.
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strFolder)
' Specify spreadsheet to be created.
strExcelPath = "C:\get_pst_info.xls"
' Create workbook.
Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.Add
' Bind to worksheet.
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)
objExcel.Cells(1, 1).Value = "Nome"
objExcel.Cells(1, 2).Value = "Ficheiro"
objExcel.Cells(1, 3).Value = "Data Criação"
objExcel.Cells(1, 4).Value = "Data Última Modificação"
objExcel.Cells(1, 5).Value = "Atributos"
objExcel.Cells(1, 6).Value = "Tamanho (bytes)"
objExcel.Cells(1, 7).Value = "Caminho"
objExcel.Range("A1:B1:C1:D1:E1:F1:G1").Select
objExcel.Range("A1:G1").Columns.AutoFit
objExcel.Range("A2:G2").Rows.Autofit
objExcel.Selection.Interior.ColorIndex = 19
objExcel.Selection.Font.ColorIndex = 11
objExcel.Selection.Font.Bold = True
' Enumerate files.
intRow = 0
Call GetFiles(objFolder)
' Save spreadsheet, close workbook, and quit Excel.
objExcel.ActiveWorkbook.SaveAs strExcelPath, xlExcel7
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit
' Alert user.
Wscript.Echo "Done"
Sub GetFiles(ByVal objParent)
' Enumerate files in folder.
' Variable intRow must have global scope.
Dim objFile, objChild
For Each objFile In objParent.Files
intRow = intRow + 2
objSheet.Cells(intRow, 1).value = objFile.Name
objSheet.Cells(intRow, 2).value = objFile.Type
objSheet.Cells(intRow, 3).value = objFile.DateCreated
objSheet.Cells(intRow, 4).Value = objFile.DateLastModified
objSheet.Cells(intRow, 5).value = objFile.Attributes
objSheet.Cells(intRow, 6).value = objFile.Size
objSheet.Cells(intRow, 7).Value = objFile.Path
Next
' Recurse through nested folders.
For Each objChild In objParent.SubFolders
Call GetFiles(objChild)
Next
End Sub
==========================================================
Can anyone help me to adapt for the changes i want to implement ?
Thanks in advance,
Marex