I have my VBscript which will convert the data from specific folder (e.g. C:) to text file with file sizes. My problem here is, my file size is converting to bytes instead of kb. Any idea how i can modify this script to get the exact file size in kb? Below is my VBscript:
Dim fso
Dim ObjFolder
Dim ObjOutFile
Dim ObjFiles
Dim ObjFile
'Creating File System Object
Set fso = CreateObject("Scripting.FileSystemObject")
'Getting the Folder Object
Set ObjFolder = fso.GetFolder("C:\Users\User\Desktop\Folder A")
'Creating an Output File to write the File sizes
Set ObjOutFile = fso.CreateTextFile("C:\Users\User\Desktop\IDENTIFIYING ZERO FILE SIZE KB.txt")
'Getting the list of Files
Set ObjFiles = ObjFolder.Files
'Writing sizes and Path of each File to Output File
For Each ObjFile In ObjFiles
ObjOutFile.WriteLine(ObjFile.size & String(50 - Len(ObjFile.size), " ") & ObjFile.Path)
Next
ObjOutFile.Close
Best Answer
Divide the size by 1024 to get it in kB and round the value to the appropriate number of digits (e.g. 2):