New
#1271
Thanks @jbcarreon123.
That sounds very interesting and will be VERY useful for those of us who dabble in Commands.
In the above output, the size unit is still "GB" even if the size is less than 1 GB, for example .04 GB.
In the attached script, the size unit becomes "MB" if the size is less than 1 GB. See my example below:
Code:Drive Letter Drive Label File System Free Space Used Space Total Space Free (%) ------------ ----------- ----------- ---------- ---------- ----------- -------- VTOYEFI FAT 9.24 MB 22.50 MB 31.74 MB 29 % Recovery NTFS 83.69 MB 415.30 MB 499.00 MB 17 % C Windows 10 NTFS 50.98 GB 29.42 GB 80.40 GB 63 % D Data NTFS 326.72 GB 58.04 GB 384.76 GB 85 % E DEVICE FAT32 7.03 GB 172.56 MB 7.20 GB 98 % F EXTRA FAT32 18.89 GB 1.98 GB 20.87 GB 91 % I SD CARD 1 FAT32 1.80 GB 93.28 MB 1.89 GB 95 % K SD CARD2 FAT32 1.75 GB 35.24 MB 1.79 GB 98 % L Windows ISO NTFS 2.21 GB 5.79 GB 8.00 GB 28 % Y Ventoy exFAT 56.45 GB 3.55 GB 60.00 GB 94 % Z .00 MB .00 MB .00 MB
Hello @Matthew Wai,
VERY NICE Matthew.
I have compiled it into a single Command and added 2 Decimal points for anyone interested . . .
Code:PowerShell "Get-volume | Sort DriveLetter | FT -A @{l='Drive Letter';E={($_.DriveLetter)};align='Left'}, @{l='Drive Label';E={($_.FileSystemLabel)};align='Left'}, @{l='File System';E={($_.FileSystem)}}, @{l='Free Space';E={;If ($_.SizeRemaining -lt 1073741824) {;[Math]::round($_.SizeRemaining / 1MB, 2, 00).ToString('#.00 MB')} else {;[Math]::round($_.SizeRemaining / 1GB, 2, 00).ToString('#.00 GB')}};A='Right'}, @{l='Used Space';E={;If ($_.Size - $_.SizeRemaining -lt 1073741824) {;[Math]::round(($_.Size - $_.SizeRemaining) / 1MB, 2, 00).ToString('#.00 MB')} else {;[Math]::round(($_.Size - $_.SizeRemaining) / 1GB, 2, 00).ToString('#.00 GB')}};A='Right'}, @{l='Total Space';E={;If ($_.Size -lt 1073741824) {;[Math]::round($_.Size / 1MB, 2, 00).ToString('#.00 MB')} else {;[Math]::round($_.Size / 1GB, 2, 00).ToString('#.00 GB')}};A='Right'}, @{l='Free (%)';E={;[Math]::round(($_.Sizeremaining / $_.Size)*100, 2).ToString('#.00') };A='Right'}" Drive Letter Drive Label File System Free Space Used Space Total Space Free (%) ------------ ----------- ----------- ---------- ---------- ----------- -------- System Reserved NTFS 121.37 MB 457.63 MB 579.00 MB 20.96 C Win_10 NTFS 16.67 GB 13.36 GB 30.03 GB 55.52 D Data NTFS 6.89 GB 10.89 GB 17.79 GB 38.76 E .00 MB .00 MB .00 MB S System_Image NTFS 6.04 GB 979.43 MB 7.00 GB 86.34
I improved it.
Code:powershell "Get-volume | Sort DriveLetter | FT -A @{l="""Drive Letter""";E={;If ($_.DriveLetter -eq $NULL) {'Hidden'} else {($_.DriveLetter)}};align='Center'}, @{l='Drive Label';E={;If ($_.FileSystemLabel -eq '') {'NO LABEL'} else {($_.FileSystemLabel)}};align='left'}, @{l='File System';E={;If ($_.FileSystemType -eq '') {'Unknown'} else {($_.FileSystemType)}};align='center'}, @{l='Free Space';E={;If ($_.SizeRemaining -eq '0') {''} else {If ($_.Size -eq '0') {''} else {If ($_.SizeRemaining -lt 1073741824) {;[Math]::round($_.SizeRemaining / 1MB, 2, 00).ToString('#.00 MB')} else {;[Math]::round($_.SizeRemaining / 1GB, 2, 00).ToString('#.00 GB')}}}};A='Right'}, @{l='Used Space';E={;If ($_.SizeRemaining -eq '0') {''} else {If ($_.Size - $_.SizeRemaining -lt 1073741824) {;[Math]::round(($_.Size - $_.SizeRemaining) / 1MB, 2, 00).ToString('#.00 MB')} else {;[Math]::round(($_.Size - $_.SizeRemaining) / 1GB, 2, 00).ToString('#.00 GB')}}};A='Right'}, @{l='Total Space';E={;If ($_.Size -eq '0') {''} else {If ($_.Size -lt 1073741824) {;[Math]::round($_.Size / 1MB, 2, 00).ToString('#.00 MB')} else {;[Math]::round($_.Size / 1GB, 2, 00).ToString('#.00 GB')}}};A='Right'}, @{l='Free (%)';E={;[Math]::round(($_.Sizeremaining / $_.Size)*100, 2).ToString('#.00') };A='Right'}"@Paul Black,Code:Microsoft Windows [Version 10.0.22000.434] (c) Microsoft Corporation. All rights reserved. ============================== jbcarreon123's CMD AutoRun ------------------------------ PC Name: JB-PC RunAs Admin? False Windows Version: Microsoft Windows 11 Pro ============================== C:\Users\jbcarreon123>powershell "Get-volume | Sort DriveLetter | FT -A @{l="""Drive Letter""";E={;If ($_.DriveLetter -eq $NULL) {'Hidden'} else {($_.DriveLetter)}};align='Center'}, @{l='Drive Label';E={;If ($_.FileSystemLabel -eq '') {'NO LABEL'} else {($_.FileSystemLabel)}};align='left'}, @{l='File System';E={;If ($_.FileSystemType -eq '') {'Unknown'} else {($_.FileSystemType)}};align='center'}, @{l='Free Space';E={;If ($_.SizeRemaining -eq '0') {''} else {If ($_.Size -eq '0') {''} else {If ($_.SizeRemaining -lt 1073741824) {;[Math]::round($_.SizeRemaining / 1MB, 2, 00).ToString('#.00 MB')} else {;[Math]::round($_.SizeRemaining / 1GB, 2, 00).ToString('#.00 GB')}}}};A='Right'}, @{l='Used Space';E={;If ($_.SizeRemaining -eq '0') {''} else {If ($_.Size - $_.SizeRemaining -lt 1073741824) {;[Math]::round(($_.Size - $_.SizeRemaining) / 1MB, 2, 00).ToString('#.00 MB')} else {;[Math]::round(($_.Size - $_.SizeRemaining) / 1GB, 2, 00).ToString('#.00 GB')}}};A='Right'}, @{l='Total Space';E={;If ($_.Size -eq '0') {''} else {If ($_.Size -lt 1073741824) {;[Math]::round($_.Size / 1MB, 2, 00).ToString('#.00 MB')} else {;[Math]::round($_.Size / 1GB, 2, 00).ToString('#.00 GB')}}};A='Right'}, @{l='Free (%)';E={;[Math]::round(($_.Sizeremaining / $_.Size)*100, 2).ToString('#.00') };A='Right'}" Drive Letter Drive Label File System Free Space Used Space Total Space Free (%) ------------ ----------- ----------- ---------- ---------- ----------- -------- Hidden NO LABEL NTFS 85.09 MB 525.91 MB 611.00 MB 13.93 C Windows 11 NTFS 75.19 GB 35.90 GB 111.09 GB 67.69 D Data NTFS 82.46 GB 28.76 GB 111.22 GB 74.15 E NO LABEL Unknown F Test Volume [SSD] NTFS 508.64 MB 53.36 MB 562.00 MB 90.51 G Ventoy NTFS 178.62 MB 14.24 GB 14.41 GB 1.21 H NO LABEL Unknown I VTOYEFI FAT 4.93 MB 26.80 MB 31.74 MB 15.54 C:\Users\jbcarreon123>
Can't manage to fit the whole new command to my execution time.
But I managed to make this:Code:C:\Users\jbcarreon123>D:\Check_CMD_EXE_Exec_Time.bat C:\Users\jbcarreon123>echo Command? or EXE name? Command? or EXE name? C:\Users\jbcarreon123>echo Ex: PowerShell Ex: PowerShell C:\Users\jbcarreon123>set /p "s1=>" > C:\Users\jbcarreon123>echo. C:\Users\jbcarreon123>echo Parameters? Parameters? C:\Users\jbcarreon123>echo Ex: -Command {Get-Disk} Ex: -Command {Get-Disk} C:\Users\jbcarreon123>set /p "s2=>" > C:\Users\jbcarreon123>echo. C:\Users\jbcarreon123>echo Start by pressing any key Start by pressing any key C:\Users\jbcarreon123>pause 1>nul C:\Users\jbcarreon123>for /F "tokens=1-4 delims=:.," %a in ("21:58:09.17") do (set /A "start=(((%a*60)+1%b % 100)*60+1%c % 100)*100+1%d % 100" ) C:\Users\jbcarreon123>(set /A "start=(((21*60)+158 % 100)*60+109 % 100)*100+117 % 100" ) C:\Users\jbcarreon123>set "timest=21:58:09.17" C:\Users\jbcarreon123>PowerShell "Get-volume | Sort DriveLetter | FT -A @{l="""Drive Letter""";E={;If ($_.DriveLetter -eq $NULL) {'Hidden'} else {($_.DriveLetter)}};align='Center'}, @{l='Drive Label';E={;If ($_.FileSystemLabel -eq '') {'NO LABEL'} else {($_.FileSystemLabel)}};align='left'}, @{l='File System';E={;If ($_.FileSystemType -eq '') {'Unknown'} else {($_.FileSystemType)}};align='center'}, @{l='Free Space';E={;If ($_.SizeRemaining -eq '0') {''} else {If ($_.Size -eq '0') {''} else {If ($_.SizeRemaining -lt 1073741824) {;[Math]::round($_.SizeRemaining / 1MB, 2, 00).ToString('#.00 MB')} else {;[Math]::round($_.SizeRemaining / 1GB, 2, 00).ToString('#.00 GB')}}}};A='Right'}, @{l='Used Space';E={;If ($_.SizeRemaining -eq '0') {''} else {If ($_.Size - $_.SizeRemaining -lt 1073741824) {;[Math]::round(($_.Size - $_.SizeRemaining) / 1MB, 2, 00).ToString('#.00 MB')} else {;[Math]::round(($_.Size - $_.SizeRemaining) / 1GB, 2, 00).ToString('#.00 GB')}}};A='Right'}, @{l='Total Space';E={;If ($_.Size -eq '0') {''} else {If ($_.Size -lt 10737418 Missing closing ')' after expression in 'If' statement. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : MissingEndParenthesisAfterStatement C:\Users\jbcarreon123>set "timef=21:58:09.54" C:\Users\jbcarreon123>rem Get end time: C:\Users\jbcarreon123>rem Get end time: C:\Users\jbcarreon123>for /F "tokens=1-4 delims=:.," %a in ("21:58:09.54") do (set /A "end=(((%a*60)+1%b % 100)*60+1%c % 100)*100+1%d % 100" ) C:\Users\jbcarreon123>(set /A "end=(((21*60)+158 % 100)*60+109 % 100)*100+154 % 100" ) C:\Users\jbcarreon123>rem Get elapsed time: C:\Users\jbcarreon123>set /A elapsed=end-start C:\Users\jbcarreon123>rem Show elapsed time: C:\Users\jbcarreon123>set /A hh=elapsed/(60*60*100), rest=elapsed%(60*60*100), mm=rest/(60*100), rest%=60*100, ss=rest/100, cc=rest%100 C:\Users\jbcarreon123>if 0 LSS 10 set mm=00 C:\Users\jbcarreon123>if 0 LSS 10 set ss=00 C:\Users\jbcarreon123>if 37 LSS 10 set cc=037 C:\Users\jbcarreon123>echo. C:\Users\jbcarreon123>echo The Runtime is: The Runtime is: C:\Users\jbcarreon123>echo 00 Minutes 00 Minutes C:\Users\jbcarreon123>echo 00 Seconds 00 Seconds C:\Users\jbcarreon123>echo. C:\Users\jbcarreon123>echo Press any key to exit. Press any key to exit. C:\Users\jbcarreon123>
Check_CMD_EXE_Exec_Time.batCode:C:\Users\jbcarreon123>D:\Check_CMD_EXE_Exec_Time.bat Command? or EXE name? Ex: PowerShell >cmd Parameters? Ex: -Command {Get-Disk} >/c dir Start by pressing any key ============================== jbcarreon123's CMD AutoRun ------------------------------ PC Name: JB-PC RunAs Admin? False Windows Version: Microsoft Windows 11 Pro ============================== Volume in drive C is Windows 11 Volume Serial Number is 6229-FA50 Directory of C:\Users\jbcarreon123 01/21/2022 05:30 PM <DIR> . 01/09/2022 04:08 AM <DIR> .. 01/22/2022 05:47 PM <DIR> .elevenclock 01/09/2022 09:13 PM <DIR> .VirtualBox 01/09/2022 04:07 AM <DIR> Contacts 01/11/2022 01:04 PM 295,290 eventlog.txt 01/09/2022 04:07 AM <DIR> Favorites 01/11/2022 10:28 PM 1,014 File2EXE.bat 01/11/2022 09:55 PM 858 File2EXE.bat.bak 01/09/2022 04:07 AM <DIR> Links 01/09/2022 04:07 AM <DIR> Music 01/11/2022 12:01 PM <DIR> OneDrive 01/08/2022 08:41 PM <DIR> Pictures 01/09/2022 04:07 AM <DIR> Saved Games 01/08/2022 08:44 PM <DIR> Searches 11/30/2021 11:47 AM 23,145 Tuneup_plus_log.bat 01/12/2022 06:20 PM <DIR> Videos 01/09/2022 09:10 PM <DIR> VirtualBox VMs 4 File(s) 320,307 bytes 14 Dir(s) 80,732,180,480 bytes free The Runtime is: 00 Minutes 00 Seconds Press any key to exit. C:\Users\jbcarreon123>
Feel free to publish this to Batch Scripts / Programs.
Hello @jbcarreon123,
I REALLY like the addition of theHidden
andNO LABEL
entries. That suits my OCD to no end.
I will have a look at the .bat file later, and I am sure that others will also benefit.