If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Rate Thread | Display Modes |
#1
|
|||
|
|||
Get directory and subdirectory size from the command line?
Hi All,
Is there a way to get your directory/sub-directory size from straight CMD without power shell? powershell -noprofile -command "ls -r D:\drivers | measure -s Length" Count : 162 Average : Sum : 2557511012 Maximum : Minimum : Property : Length Is three a API call for this? Many thanks, -T |
Ads |
#2
|
|||
|
|||
Get directory and subdirectory size from the command line?
T wrote:
Is there a way to get your directory/sub-directory size from straight CMD without power shell? Use WSL and the du command? |
#3
|
|||
|
|||
Get directory and subdirectory size from the command line?
On 2020-05-15 12:08, Andy Burns wrote:
T wrote: Is there a way to get your directory/sub-directory size from straight CMD without power shell? Use WSL and the du command? Hi Andy, You know what, to use zef with Raku, which I will be using, you have to install GIT and it comes with a bunch of Linux commands, including `du` du -s -k c:\drivers 611909 c:\drivers And GIT comes with `df` too; df -kPT Filesystem Type 1024-blocks Used Available Capacity Mounted on C:/Program Files/Git ntfs 41838588 28815640 13022948 69% / E: iso9660 309208 309208 0 100% /e F: ntfs 8188 3908 4280 48% /f G: ntfs 10236 3908 6328 39% /g J: smbfs 951048868 514506740 436542128 55% /j K: smbfs 951048868 514506764 436542104 55% /k L: smbfs 951048868 514506784 436542084 55% /l M: ntfs 2062332 38800 2023532 2% /m Thank you! Jogged my memory! -T |
#4
|
|||
|
|||
Get directory and subdirectory size from the command line?
In response to what T wrote :
du -s -k c:\drivers 611909 c:\drivers Good suggestion, particularly since I just installed WSL last night! https://groups.google.com/d/msg/alt.msdos.batch/z5ac1dU0PzQ/nIlp-pCtAAAJ To help out, here are my results, where an "attrib" may be required... Start Run cmd{control+shift+enter} C:\ wsl $ du -s -k /mnt/c/windows Reported: 13558812 /mnt/c/windows This is a screenshot of that from moments ago... https://i.postimg.cc/4N1p9tBr/wsl01.jpg Bear in mind 'permissions' may be an issue... $ du -s -k /mnt/c/windows du: cannot read directory '/mnt/c/windows/appcompat/Programs': Permission denied du: cannot read directory '/mnt/c/windows/CSC': Permission denied du: cannot read directory '/mnt/c/windows/LiveKernelReports': Permission denied du: cannot read directory '/mnt/c/windows/Logs/SystemRestore': Permission denied du: cannot read directory '/mnt/c/windows/ModemLogs': Permission denied du: cannot read directory '/mnt/c/windows/PCHEALTH/ERRORREP/QHEADLES': Permission denied du: cannot read directory '/mnt/c/windows/PCHEALTH/ERRORREP/QSIGNOFF': Permission denied du: cannot read directory '/mnt/c/windows/PLA/Reports': Permission denied du: cannot read directory '/mnt/c/windows/PLA/Rules': Permission denied du: cannot read directory '/mnt/c/windows/PLA/Templates': Permission denied du: cannot read directory '/mnt/c/windows/Prefetch': Permission denied du: cannot read directory '/mnt/c/windows/Provisioning/Autopilot': Permission denied du: cannot read directory '/mnt/c/windows/Resources/Themes/aero/VSCache': Permission denied du: cannot read directory '/mnt/c/windows/security/audit': Permission denied du: cannot read directory '/mnt/c/windows/security/cap': Permission denied du: cannot read directory '/mnt/c/windows/ServiceProfiles/LocalService': Permission denied du: cannot read directory '/mnt/c/windows/ServiceProfiles/NetworkService': Permission denied du: cannot read directory '/mnt/c/windows/ServiceState': Permission denied du: cannot read directory '/mnt/c/windows/System32/Com/dmp': Permission denied du: cannot read directory '/mnt/c/windows/System32/config': Permission denied du: cannot read directory '/mnt/c/windows/System32/Configuration': Permission denied du: cannot read directory '/mnt/c/windows/System32/drivers/DriverData': Permission denied du: cannot read directory '/mnt/c/windows/System32/DriverState': Permission denied du: cannot read directory '/mnt/c/windows/System32/FxsTmp': Permission denied du: cannot read directory '/mnt/c/windows/System32/ias': Permission denied du: cannot read directory '/mnt/c/windows/System32/LogFiles/WMI': Permission denied du: cannot read directory '/mnt/c/windows/System32/MsDtc': Permission denied du: cannot read directory '/mnt/c/windows/System32/networklist': Permission denied du: cannot read directory '/mnt/c/windows/System32/spool/PRINTERS': Permission denied du: cannot read directory '/mnt/c/windows/System32/spool/SERVERS': Permission denied du: cannot read directory '/mnt/c/windows/System32/sru': Permission denied du: cannot read directory '/mnt/c/windows/System32/Tasks': Permission denied du: cannot read directory '/mnt/c/windows/System32/wbem/MOF': Permission denied du: cannot read directory '/mnt/c/windows/System32/WDI': Permission denied du: cannot read directory '/mnt/c/windows/SysWOW64/Com/dmp': Permission denied du: cannot read directory '/mnt/c/windows/SysWOW64/config': Permission denied du: cannot read directory '/mnt/c/windows/SysWOW64/Configuration': Permission denied du: cannot read directory '/mnt/c/windows/SysWOW64/FxsTmp': Permission denied du: cannot read directory '/mnt/c/windows/SysWOW64/Msdtc': Permission denied du: cannot read directory '/mnt/c/windows/SysWOW64/networklist': Permission denied du: cannot read directory '/mnt/c/windows/SysWOW64/sru': Permission denied du: cannot read directory '/mnt/c/windows/SysWOW64/Tasks': Permission denied du: cannot read directory '/mnt/c/windows/Temp': Permission denied 13558812 /mnt/c/windows |
#5
|
|||
|
|||
Get directory and subdirectory size from the command line?
On 2020-05-15 13:51, Arlen Holder wrote:
In response to what T wrote : Â*du -s -k c:\drivers 611909Â* c:\drivers Good suggestion, particularly since I just installed WSL last night! https://groups.google.com/d/msg/alt.msdos.batch/z5ac1dU0PzQ/nIlp-pCtAAAJ To help out, here are my results, where an "attrib" may be required... Start Run cmd{control+shift+enter} Â*C:\ wsl Â*$ du -s -k /mnt/c/windows Reported: 13558812 /mnt/c/windows This is a screenshot of that from moments ago... https://i.postimg.cc/4N1p9tBr/wsl01.jpg Bear in mind 'permissions' may be an issue... $ du -s -k /mnt/c/windows du: cannot read directory '/mnt/c/windows/appcompat/Programs': Permission denied du: cannot read directory '/mnt/c/windows/CSC': Permission denied du: cannot read directory '/mnt/c/windows/LiveKernelReports': Permission denied du: cannot read directory '/mnt/c/windows/Logs/SystemRestore': Permission denied du: cannot read directory '/mnt/c/windows/ModemLogs': Permission denied du: cannot read directory '/mnt/c/windows/PCHEALTH/ERRORREP/QHEADLES': Permission denied du: cannot read directory '/mnt/c/windows/PCHEALTH/ERRORREP/QSIGNOFF': Permission denied du: cannot read directory '/mnt/c/windows/PLA/Reports': Permission denied du: cannot read directory '/mnt/c/windows/PLA/Rules': Permission denied du: cannot read directory '/mnt/c/windows/PLA/Templates': Permission denied du: cannot read directory '/mnt/c/windows/Prefetch': Permission denied du: cannot read directory '/mnt/c/windows/Provisioning/Autopilot': Permission denied du: cannot read directory '/mnt/c/windows/Resources/Themes/aero/VSCache': Permission denied du: cannot read directory '/mnt/c/windows/security/audit': Permission denied du: cannot read directory '/mnt/c/windows/security/cap': Permission denied du: cannot read directory '/mnt/c/windows/ServiceProfiles/LocalService': Permission denied du: cannot read directory '/mnt/c/windows/ServiceProfiles/NetworkService': Permission denied du: cannot read directory '/mnt/c/windows/ServiceState': Permission denied du: cannot read directory '/mnt/c/windows/System32/Com/dmp': Permission denied du: cannot read directory '/mnt/c/windows/System32/config': Permission denied du: cannot read directory '/mnt/c/windows/System32/Configuration': Permission denied du: cannot read directory '/mnt/c/windows/System32/drivers/DriverData': Permission denied du: cannot read directory '/mnt/c/windows/System32/DriverState': Permission denied du: cannot read directory '/mnt/c/windows/System32/FxsTmp': Permission denied du: cannot read directory '/mnt/c/windows/System32/ias': Permission denied du: cannot read directory '/mnt/c/windows/System32/LogFiles/WMI': Permission denied du: cannot read directory '/mnt/c/windows/System32/MsDtc': Permission denied du: cannot read directory '/mnt/c/windows/System32/networklist': Permission denied du: cannot read directory '/mnt/c/windows/System32/spool/PRINTERS': Permission denied du: cannot read directory '/mnt/c/windows/System32/spool/SERVERS': Permission denied du: cannot read directory '/mnt/c/windows/System32/sru': Permission denied du: cannot read directory '/mnt/c/windows/System32/Tasks': Permission denied du: cannot read directory '/mnt/c/windows/System32/wbem/MOF': Permission denied du: cannot read directory '/mnt/c/windows/System32/WDI': Permission denied du: cannot read directory '/mnt/c/windows/SysWOW64/Com/dmp': Permission denied du: cannot read directory '/mnt/c/windows/SysWOW64/config': Permission denied du: cannot read directory '/mnt/c/windows/SysWOW64/Configuration': Permission denied du: cannot read directory '/mnt/c/windows/SysWOW64/FxsTmp': Permission denied du: cannot read directory '/mnt/c/windows/SysWOW64/Msdtc': Permission denied du: cannot read directory '/mnt/c/windows/SysWOW64/networklist': Permission denied du: cannot read directory '/mnt/c/windows/SysWOW64/sru': Permission denied du: cannot read directory '/mnt/c/windows/SysWOW64/Tasks': Permission denied du: cannot read directory '/mnt/c/windows/Temp': Permission denied 13558812Â*Â* /mnt/c/windows Excellent! I do have all that available with Git, which I have to have to run Raku's zef -T Linux has all the cool tools :-) |
#6
|
|||
|
|||
Get directory and subdirectory size from the command line?
On Fri, 15 May 2020 11:59:41 -0700, in alt.comp.os.windows-10, T wrote:
Hi All, Is there a way to get your directory/sub-directory size from straight CMD without power shell? powershell -noprofile -command "ls -r D:\drivers | measure -s Length" Count : 162 Average : Sum : 2557511012 Maximum : Minimum : Property : Length Is three a API call for this? Many thanks, -T Yeah, the Linux is a better idea. Your only other choice was "dir /s" from wherever you want to count size. It'll appear at the end of the listing. You do that in a drive root and it takes forever, but it does work. -- Zag No one ever said on their deathbed, 'Gee, I wish I had spent more time alone with my computer.' ~Dan(i) Bunten |
#7
|
|||
|
|||
Get directory and subdirectory size from the command line?
On 2020-05-15 14:40, Zaghadka wrote:
On Fri, 15 May 2020 11:59:41 -0700, in alt.comp.os.windows-10, T wrote: Hi All, Is there a way to get your directory/sub-directory size from straight CMD without power shell? powershell -noprofile -command "ls -r D:\drivers | measure -s Length" Count : 162 Average : Sum : 2557511012 Maximum : Minimum : Property : Length Is three a API call for this? Many thanks, -T Yeah, the Linux is a better idea. Your only other choice was "dir /s" from wherever you want to count size. It'll appear at the end of the listing. You do that in a drive root and it takes forever, but it does work. Thank you! |
#8
|
|||
|
|||
Get directory and subdirectory size from the command line?
In response to what T wrote :
Yeah, the Linux is a better idea. Your only other choice was "dir /s" from wherever you want to count size. It'll appear at the end of the listing. You do that in a drive root and it takes forever, but it does work. Thank you! Doing my part to help out... By way of comparison to my WSL du results on "C:\Windows", here is a "dir /s" result to compare with. c:\ dir /s C:\Windows ... lots of stuff ... Total Files Listed: 271247 File(s) 20,534,651,243 bytes 214822 Dir(s) 858,287,794,278 bytes free Versus: Start Run cmd{control+shift+enter} c:\ wsl $ du -s -k /mnt/c/windows ... lots of stuff ... 13558812 /mnt/c/windows -- One of my favorite scripted commands is "salonb", i.e., C:\ dir /s/a/l/on/b c:\*.* 20200510salonb.txt |
#9
|
|||
|
|||
Get directory and subdirectory size from the command line?
On 2020-05-15 15:14, Arlen Holder wrote:
In response to what T wrote : Yeah, the Linux is a better idea. Your only other choice was "dir /s" from wherever you want to count size. It'll appear at the end of the listing. You do that in a drive root and it takes forever, but it does work. Thank you! Doing my part to help out... By way of comparison to my WSL du results on "C:\Windows", here is a "dir /s" result to compare with. c:\ dir /s C:\Windows Â*Â* ... lots of stuff ... Â*Â* Total Files Listed: Â*Â*Â*Â*Â*Â*Â*Â*Â* 271247 File(s) 20,534,651,243 bytes Â*Â*Â*Â*Â*Â*Â*Â*Â* 214822 Dir(s)Â* 858,287,794,278 bytes free Versus: Â*Start Run cmd{control+shift+enter} Â*c:\ wsl Â*$ du -s -k /mnt/c/windows Â*Â* ... lots of stuff ... Â*Â*Â*Â*Â*Â*Â*Â*Â* 13558812 /mnt/c/windows I am using the Linux commands from the Git install this is what I have so far: How to get directory and sub directory size: powershell -noprofile -command "ls -r D:\drivers | measure -s Length" Count : 162 Average : Sum : 2557511012 Maximum : Minimum : Property : Length If you have GIT installed du -s -k c:\drivers 611909 c:\drivers df -kPT Filesystem Type 1024-blocks Used Available Capacity Mounted on C:/Program Files/Git ntfs 41838588 28815640 13022948 69% / E: iso9660 309208 309208 0 100% /e F: ntfs 8188 3908 4280 48% /f G: ntfs 10236 3908 6328 39% /g J: smbfs 951048868 514506740 436542128 55% /j K: smbfs 951048868 514506764 436542104 55% /k L: smbfs 951048868 514506784 436542084 55% /l M: ntfs 2062332 38800 2023532 2% /m |
#10
|
|||
|
|||
Get directory and subdirectory size from the command line?
"T" wrote
| | Is there a way to get your directory/sub-directory size from | straight CMD without power shell? | I'm not sure if this is what you want, and I know you like command line, but I have this VBS script I keep on my desktop. I wrote it to look for bloat. You enter a prent folder, like C:\, and it creates a list of folder sizes, as a TXT file, going from largest to smallest. Just paste into Notepad and save as VBS. Watch out for wordwrap in the posting here. At the least, the lines that start with "sDriv =" and "s2 = " are wrapping. '--begin vbs-------- Dim FSO, s2, TS, sDriv, APath(), ASize(), iCnt, iTotal, i2 sDriv = InputBox("Enter path of folder to list sizes of all subfolders. For a drive enter X:\, where X is the drive letter.", "List Folder Sizes") If Len(sDriv) 3 Then WScript.quit Set FSO = CreateObject("Scripting.FileSystemObject") On Error Resume Next iTotal = 500 ReDim APath(iTotal) ReDim ASize(iTotal) iCnt = 0 GetFolderSizes(sDriv) iCnt = iCnt - 1 ReDim Preserve ASize(iCnt) ReDim Preserve APath(iCnt) QuickSort ASize, APath, 0, 0 For i2 = iCnt to 0 step -1 s2 = s2 & APath(i2) & " -- " & CStr(ASize(i2)) & " MB" & vbCrLf Next s2 = "Sizes of folders in " & sDriv & vbCrLf & "(Note: Sizes are in MB. A size of 0 indicates the size is between 0 and 1 MB.)" & vbCrLf & vbCrLf & s2 Set TS = FSO.CreateTextFile("C:\Folder Sizes" & left(sDriv, 1) & ".txt", True) TS.Write s2 TS.Close Set TS = Nothing MsgBox "List for " & sDriv & " is saved to C:\Folder Sizes.txt", 64 Sub GetFolderSizes(sPath) Dim oFol, oFols, oFol1, iSz, sList, s On Error Resume Next APath(iCnt) = sPath Set oFol = FSO.GetFolder(sPath) iSz = oFol.Size If iSz 1024 Then iSz = iSz / 1024: Else iSz = 0 If iSz 1024 Then iSz = iSz / 1024: Else iSz = 0 iSz = CInt(iSz) ASize(iCnt) = iSz iCnt = iCnt + 1 If iCnt + 10 iTotal Then iTotal = iTotal + 200 ReDim Preserve APath(iTotal) ReDim Preserve ASize(iTotal) End If Set oFols = oFol.SubFolders If oFols.count 0 Then For Each oFol1 in oFols GetFolderSizes(oFol1.Path) Next End If Set oFols = Nothing Set oFol = Nothing End Sub Sub QuickSort(AIn1, AIn2, LBeg, LEnd) Dim LBeg2, vMid, LEnd2, vSwap1, vSwap2 On Error Resume Next If (LEnd = 0) Then LEnd = UBound(AIn1) LBeg2 = LBeg LEnd2 = LEnd vMid = AIn1((LBeg + LEnd) \ 2) Do Do While AIn1(LBeg2) vMid And LBeg2 LEnd LBeg2 = LBeg2 + 1 Loop Do While vMid AIn1(LEnd2) And LEnd2 LBeg LEnd2 = LEnd2 - 1 Loop If LBeg2 = LEnd2 Then vSwap1 = AIn1(LBeg2) vSwap2 = AIn2(LBeg2) AIn1(LBeg2) = AIn1(LEnd2) AIn2(LBeg2) = AIn2(LEnd2) AIn1(LEnd2) = vSwap1 AIn2(LEnd2) = vSwap2 LBeg2 = LBeg2 + 1 LEnd2 = LEnd2 - 1 End If Loop Until LBeg2 LEnd2 If LBeg LEnd2 Then QuickSort AIn1, AIn2, LBeg, LEnd2 If LBeg2 LEnd Then QuickSort AIn1, AIn2, LBeg2, LEnd End Sub '--end script ------------------ |
#11
|
|||
|
|||
Get directory and subdirectory size from the command line?
On 2020-05-15 16:44, Mayayana wrote:
"T" wrote | | Is there a way to get your directory/sub-directory size from | straight CMD without power shell? | I'm not sure if this is what you want, and I know you like command line, but I have this VBS script I keep on my desktop. I wrote it to look for bloat. You enter a prent folder, like C:\, and it creates a list of folder sizes, as a TXT file, going from largest to smallest. Just paste into Notepad and save as VBS. Watch out for wordwrap in the posting here. At the least, the lines that start with "sDriv =" and "s2 = " are wrapping. '--begin vbs-------- Dim FSO, s2, TS, sDriv, APath(), ASize(), iCnt, iTotal, i2 sDriv = InputBox("Enter path of folder to list sizes of all subfolders. For a drive enter X:\, where X is the drive letter.", "List Folder Sizes") If Len(sDriv) 3 Then WScript.quit Set FSO = CreateObject("Scripting.FileSystemObject") On Error Resume Next iTotal = 500 ReDim APath(iTotal) ReDim ASize(iTotal) iCnt = 0 GetFolderSizes(sDriv) iCnt = iCnt - 1 ReDim Preserve ASize(iCnt) ReDim Preserve APath(iCnt) QuickSort ASize, APath, 0, 0 For i2 = iCnt to 0 step -1 s2 = s2 & APath(i2) & " -- " & CStr(ASize(i2)) & " MB" & vbCrLf Next s2 = "Sizes of folders in " & sDriv & vbCrLf & "(Note: Sizes are in MB. A size of 0 indicates the size is between 0 and 1 MB.)" & vbCrLf & vbCrLf & s2 Set TS = FSO.CreateTextFile("C:\Folder Sizes" & left(sDriv, 1) & ".txt", True) TS.Write s2 TS.Close Set TS = Nothing MsgBox "List for " & sDriv & " is saved to C:\Folder Sizes.txt", 64 Sub GetFolderSizes(sPath) Dim oFol, oFols, oFol1, iSz, sList, s On Error Resume Next APath(iCnt) = sPath Set oFol = FSO.GetFolder(sPath) iSz = oFol.Size If iSz 1024 Then iSz = iSz / 1024: Else iSz = 0 If iSz 1024 Then iSz = iSz / 1024: Else iSz = 0 iSz = CInt(iSz) ASize(iCnt) = iSz iCnt = iCnt + 1 If iCnt + 10 iTotal Then iTotal = iTotal + 200 ReDim Preserve APath(iTotal) ReDim Preserve ASize(iTotal) End If Set oFols = oFol.SubFolders If oFols.count 0 Then For Each oFol1 in oFols GetFolderSizes(oFol1.Path) Next End If Set oFols = Nothing Set oFol = Nothing End Sub Sub QuickSort(AIn1, AIn2, LBeg, LEnd) Dim LBeg2, vMid, LEnd2, vSwap1, vSwap2 On Error Resume Next If (LEnd = 0) Then LEnd = UBound(AIn1) LBeg2 = LBeg LEnd2 = LEnd vMid = AIn1((LBeg + LEnd) \ 2) Do Do While AIn1(LBeg2) vMid And LBeg2 LEnd LBeg2 = LBeg2 + 1 Loop Do While vMid AIn1(LEnd2) And LEnd2 LBeg LEnd2 = LEnd2 - 1 Loop If LBeg2 = LEnd2 Then vSwap1 = AIn1(LBeg2) vSwap2 = AIn2(LBeg2) AIn1(LBeg2) = AIn1(LEnd2) AIn2(LBeg2) = AIn2(LEnd2) AIn1(LEnd2) = vSwap1 AIn2(LEnd2) = vSwap2 LBeg2 = LBeg2 + 1 LEnd2 = LEnd2 - 1 End If Loop Until LBeg2 LEnd2 If LBeg LEnd2 Then QuickSort AIn1, AIn2, LBeg, LEnd2 If LBeg2 LEnd Then QuickSort AIn1, AIn2, LBeg2, LEnd End Sub '--end script ------------------ Interesting. Thank you! |
#12
|
|||
|
|||
Get directory and subdirectory size from the command line?
Arlen Holder schreef:
One of my favorite scripted commands is "salonb", i.e., C:\ dir /s/a/l/on/b c:\*.* 20200510salonb.txt In cmd it messes up non-ascii characters in file names. The powershell handles it correctly. -- Alex. |
#13
|
|||
|
|||
Get directory and subdirectory size from the command line?
On 2020-05-17 12:31 p.m., Alex Plantema wrote:
Arlen Holder schreef: One of my favorite scripted commands is "salonb", i.e., C:\ dir /s/a/l/on/b c:\*.* 20200510salonb.txt In cmd it messes up non-ascii characters in file names. The powershell handles it correctly. I've got a Unix command line on my system: "du -d 1 -h directory" Change "1" to whatever level of depth you'd like for the information. :-) |
#14
|
|||
|
|||
Get directory and subdirectory size from the command line?
On 2020-05-18 22:06, Alan Baker wrote:
On 2020-05-17 12:31 p.m., Alex Plantema wrote: Arlen Holder schreef: One of my favorite scripted commands is "salonb", i.e., C:\ dir /s/a/l/on/b c:\*.* 20200510salonb.txt In cmd it messes up non-ascii characters in file names. The powershell handles it correctly. I've got a Unix command line on my system: "du -d 1 -h directory" Change "1" to whatever level of depth you'd like for the information. :-) I got that command when I installed Git to support Raku. The command line got a lot easier :-) |
Thread Tools | |
Display Modes | Rate This Thread |
|
|