Follow

Troubleshooting: List/Sort files by size

Question:
How do I list the top X (10, 20, etc.) files by size (largest down - descending order)?

Where applicable:
Your system may be running out of disk space and you may want to identify the largest files on the system

Tip: We recommend that you build two lists two hours apart so that the results may be compared

Answer:

Note:
- Replace TRAVERSE_HOME with the Traverse installation directory on your system
- Make sure the long command below is all typed in one line
- The example below lists the top 20 files by descending size (select -first 20)

Open a DOS command prompt using 'Run As Administrator' and launch powershell

C:\Windows\system32>powershell
PS C:\Windows\system32> $FormatEnumerationLimit=-1

PS C:\Windows\system32>cd TRAVERSE_HOME
PS C:\Program Files (x86)\Traverse> Get-ChildItem -Path . -Recurse -Force | Where-Object { !$_.PSIsContainer } | Select-Object -Property FullName,@{Name='SizeGB
';Expression={$_.Length / 1GB}} | Sort-Object { $_.SizeGB } -Desc| select -first 20 | Out-String -Width 240

FullName
SizeGB
--------
------
C:\Program Files (x86)\Traverse\database\mysql\aggregateddatadb\messages.MYD
6.44907046109438
C:\Program Files (x86)\Traverse\database\backup\backup_aggregateddatadb\messages.MYD
6.44785480573773
C:\Program Files (x86)\Traverse\database\mysql\aggregateddatadb\messages.MYI
1.87986183166504
C:\Program Files (x86)\Traverse\bin\hs_err_pid2044.mdmp
1.38238046877086
C:\Program Files (x86)\Traverse\database\mysql\aggregateddatadb\aggregationdatascheme2.MYD
1.31448789127171
C:\Program Files (x86)\Traverse\database\backup\backup_aggregateddatadb\aggregationdatascheme2.MYD
1.31448789127171
C:\Program Files (x86)\Traverse\database\mysql\aggregateddatadb\userevent.MYI
0.82502269744873
C:\Program Files (x86)\Traverse\database\mysql\aggregateddatadb\userevent.MYD
0.82455737143755
C:\Program Files (x86)\Traverse\database\backup\backup_aggregateddatadb\userevent.MYD
0.82455737143755
C:\Program Files (x86)\Traverse\database\mysql\aggregateddatadb\aggregationdatascheme2.MYI
0.509856224060059
C:\Program Files (x86)\Traverse\database\backup\backup_aggregateddatadb\aggregationdatascheme1.MYD
0.501284742727876
C:\Program Files (x86)\Traverse\database\mysql\aggregateddatadb\aggregationdatascheme1.MYD
0.501284742727876
C:\Program Files (x86)\Traverse\database\mysql\aggregateddatadb\aggregationdatascheme0.MYD
0.222308347932994
C:\Program Files (x86)\Traverse\database\backup\backup_aggregateddatadb\aggregationdatascheme0.MYD
0.222308347932994
C:\Program Files (x86)\Traverse\database\mysql\aggregateddatadb\aggregationdatascheme1.MYI
0.187067031860352
C:\Program Files (x86)\Traverse\database\backup\backup_aggregateddatadb\aggregationdatascheme3.MYD
0.142579710111022
C:\Program Files (x86)\Traverse\database\mysql\aggregateddatadb\aggregationdatascheme3.MYD
0.142579710111022
C:\Program Files (x86)\Traverse\uninstall\.com.zerog.registry.xml
0.101473740302026
C:\Program Files (x86)\Traverse\01-OLD_VERSION\database\export.xml
0.0990461139008403
C:\Program Files (x86)\Traverse\database\mysql\aggregateddatadb\aggregationdatascheme0.MYI
0.0825843811035156

 

References:
find the 10 largest files within a directory structure
Find Largest (Or Smallest) Files In A Directory Or Drive With PowerShell
Viewing Truncated PowerShell Output

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.