CCG3
asked on
Modify Output to show folder size output in MBs
need help changing this VBS script to output MBs instead of bytes (fsize at the bottom)
On Error Resume Next
inputfile="C:\folderlist.x ls" 'path of excel file
outputfile="C:\output.txt" 'path of output file to be written
Set objExcel = CreateObject("Excel.Applic ation")
Set objWorkbook = objExcel.Workbooks.Open(in putfile)
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
Set outputfile=objfso.OpenText File(outpu tfile,2)
intRow = 1
Do Until objExcel.Cells(intRow,1).V alue = ""
strcomputer=Trim(objExcel. Cells(intR ow, 1).Value)
folder=Trim(objExcel.Cells (intRow, 2).Value)
folder_path="\\"&strcomput er&"\"& folder
WScript.Echo folder_path
Set objShell = CreateObject("Wscript.Shel l")
command = "du.exe " & folder_path
Set objExec = objShell.Exec(Command)
Do While Not objExec.StdOut.AtEndOfStre am
strText = Trim(objExec.StdOut.ReadLi ne())
' Test or display strText
WScript.Echo strText
If InStr(strText,"Size: ")>0 Then
fsize=Replace(strText,"Siz e: ","")
fsize=Replace(fsize," bytes","")
fsizedbl=CDbl(fsize)
WScript.Echo "File size " & fsizedbl
outputfile.WriteLine strcomputer & "," & folder & "," & fsize
Exit Do
End If
Loop
intRow = intRow + 1
Loop
outputfile.Close
objExcel.Quit
On Error Resume Next
inputfile="C:\folderlist.x
outputfile="C:\output.txt"
Set objExcel = CreateObject("Excel.Applic
Set objWorkbook = objExcel.Workbooks.Open(in
Set objFSO = CreateObject("Scripting.Fi
Set outputfile=objfso.OpenText
intRow = 1
Do Until objExcel.Cells(intRow,1).V
strcomputer=Trim(objExcel.
folder=Trim(objExcel.Cells
folder_path="\\"&strcomput
WScript.Echo folder_path
Set objShell = CreateObject("Wscript.Shel
command = "du.exe " & folder_path
Set objExec = objShell.Exec(Command)
Do While Not objExec.StdOut.AtEndOfStre
strText = Trim(objExec.StdOut.ReadLi
' Test or display strText
WScript.Echo strText
If InStr(strText,"Size: ")>0 Then
fsize=Replace(strText,"Siz
fsize=Replace(fsize," bytes","")
fsizedbl=CDbl(fsize)
WScript.Echo "File size " & fsizedbl
outputfile.WriteLine strcomputer & "," & folder & "," & fsize
Exit Do
End If
Loop
intRow = intRow + 1
Loop
outputfile.Close
objExcel.Quit
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.