I have noticed that the "size" property of an NTFS compressed file actually returns its uncompressed size and I can't seem to find a way to get the actual size on disk.
I would need this value in order to know the real weight of specific folders that contain compressed data.
Is there a way to do this in VBS ?
Thanks !
Here's how you execute the same program without having to search for a file individually, using a "UserAccounts.CommonDialog" which isn't active in all OS's anymore, also, I cleaned up the code so it only displays the size on disk and not any other redundant info.
Enjoy.
Dim sFile : sFile = "C:\testenv\compressed\test.txt"
Dim oShell, oFSO, oEnv, oNet
Set oShell = CreateObject("Wscript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oEnv = oShell.Environment("Process")
Set oNet = WScript.CreateObject("WScript.Network")
Dim sTempFile, aText, i, aInfo
sTempFile = oFSO.GetAbsolutePathName(oFSO.GetTempName)
oShell.Run "%comspec% /c compact " & Chr(34) & sFile & Chr(34) & " > " & Chr(34) & sTempFile & Chr(34), 0, True
aText = Split(oFSO.OpenTextFile(sTempFile,1).ReadAll,vbCrLf)
If oFSO.FileExists(sTempFile) Then oFSO.DeleteFile sTempFile, True
For i = 0 To UBound(aText)
If InStr(aText(i),oFSO.GetBaseName(sFile)) Then
aInfo = Split(Replace(aText(i),"=",":"), ":")
If IsNumeric(Trim(aInfo(1))) Then
WScript.Echo sFile & " : Size on Disk = " & FormatNumber(Trim(aInfo(1)), 0) & " bytes"
End If
End If
Next