0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PowerShellで指定したディレクトリ以下の容量が大きいファイルTOP30を表示する

Last updated at Posted at 2025-10-27

昇順で表示

Get-ChildItem c:\sample\ -Recurse |
    Select-Object FullName , Length |
    Sort-Object Length -Descending | 
    Select-Object -first 30
FullName                                 Length
--------                                 ------
C:\sample\プロセス監視\結合テスト1.xlsx   2583414
C:\sample\プロセス監視\結合テスト2.xlsx   1233434
C:\sample\プロセス監視\結合テスト15.xlsx   454534
C:\sample\プロセス監視\単体テスト1.xlsx    443243
C:\sample\プロセス監視\単体テスト1.xlsx    123324
...
...

上記をメガ表記で

Get-ChildItem C:\sample -Recurse | 
    Sort-Object Length -Descending | 
    Select-Object -first 30 | 
    Select-Object FullName, @{Name="Length(MB)"; Expression={"{0:N2} MB" -f ($_.Length / 1MB)}}
FullName                                 Length(MB)
--------                                ----------
C:\sample\プロセス監視\結合テスト1.xlsx      2.56 MB
C:\sample\プロセス監視\結合テスト2.xlsx      1.22 MB
C:\sample\プロセス監視\結合テスト15.xlsx     0.46 MB
C:\sample\プロセス監視\単体テスト1.xlsx      0.44 MB
C:\sample\プロセス監視\単体テスト1.xlsx      0.13 MB
...
...

(おまけ)Linuxで言うところのfindコマンド

Get-ChildItem -Recurse -Filter "*.txt"
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?