All Forums
> Network Scanner
> Current topic
How to get "Used Space"
Started by Drada
How to get "Used Space" 12 March 2024, 14:47 |
Registered: 6 months ago Posts: 4 |
Re: How to get "Used Space" 12 March 2024, 19:36 |
Admin Registered: 18 years ago Posts: 3 559 |
At the device level you can use Remote Scripting. Choose Options - Remote Scripting - New and add the following script:
' Function to convert a size string into megabytes Function ConvertToMB(sizeString) Dim numberPart Dim unitPart Dim valueInMB ' Split the size string into the numeric and unit parts numberPart = CDbl(Split(sizeString, " ")(0)) unitPart = UCase(Trim(Split(sizeString, " ")(1))) ' Convert the size to MB based on the unit Select Case unitPart Case "MB" valueInMB = numberPart Case "GB" valueInMB = numberPart * 1024 Case "TB" valueInMB = numberPart * 1024 * 1024 Case Else valueInMB = 0 End Select ConvertToMB = valueInMB End Function ' Function to format a size in MB into a more readable string Function FormatSize(sizeInMB) Dim formattedSize ' Convert and format the size based on its magnitude If sizeInMB < 1024 Then formattedSize = sizeInMB & " MB" ElseIf sizeInMB < 1024 * 1024 Then formattedSize = FormatNumber(sizeInMB / 1024, 2) & " GB" Else formattedSize = FormatNumber(sizeInMB / (1024 * 1024), 2) & " TB" End If FormatSize = formattedSize End Function ' Function to find the difference between two size strings Function FindDifference(size1, size2) Dim sizeInMB1 Dim sizeInMB2 Dim differenceInMB ' Convert both sizes to MB sizeInMB1 = ConvertToMB(size1) sizeInMB2 = ConvertToMB(size2) ' Calculate the absolute difference differenceInMB = Abs(sizeInMB1 - sizeInMB2) ' Format and return the difference FindDifference = FormatSize(differenceInMB) End Function Function IsNotEmpty(str) If Len(str) > 0 Then IsNotEmpty = True Else IsNotEmpty = False End If End Function freeSpace = Input.Column("free space") totalSpace = Input.Column("total space") If IsNotEmpty(freeSpace) And IsNotEmpty(totalSpace) Then Output.Write FindDifference(freeSpace, totalSpace) End ifSample output:
Re: How to get "Used Space" 12 March 2024, 22:27 |
Registered: 6 months ago Posts: 4 |
Mat
Re: How to get "Used Space" 13 March 2024, 04:32 |
Re: How to get "Used Space" 13 March 2024, 11:38 |
Admin Registered: 18 years ago Posts: 3 559 |
QuoteDrada
But why is there no data after "Rescan Device" - "Used Space" if the device is turned off? At the same time, the freespace and totalspace columns have same meanings.
Sorry that's not something we can reproduce. I have done Rescan device - Used space and it simply turned grey:
What is happening in your case?
QuoteMat
Can you explain how do you got Free Space and Total Space values?
There is a setting under Settings - Shares that retrieves disk space information on shared folders:
Re: How to get "Used Space" 13 March 2024, 14:27 |
Registered: 6 months ago Posts: 4 |
Re: How to get "Used Space" 13 March 2024, 15:51 |
Admin Registered: 18 years ago Posts: 3 559 |
Re: How to get "Used Space" 13 March 2024, 16:41 |
Registered: 6 months ago Posts: 4 |
Re: How to get "Used Space" 13 March 2024, 18:01 |
Admin Registered: 18 years ago Posts: 3 559 |