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?

ファイル、フォルダのサイズを分析する

Posted at

概要

私なりのファイル毎やフォルダ毎のサイズを分析する方法を記載しています。
目新しいコードは書いておらず、大体はネットで調べた知識 + Excelの操作を忘れないための備忘録です。

ファイルサイズを取得する

以下の項目を修正してから、PowerShellを実行する

  • dirPath(調査対象のフォルダ(最後に\が必要))
  • exportFolder(調査結果を出力するファイルを指定。新規ファイルでも可。)
# ★★★サイズを取得する対象のフォルダを指定する★★★
$dirPath = "C:Users\Desktop\・・・\"

# ★★★結果を出力するフォルダパスを指定してください★★★
$exportFile = "C:\Users\ユーザー名\Desktop\test.csv"

# 指定したフォルダパスのファイル一覧を出力する(フルパス、フォルダパス、ファイル名、拡張子、
Get-ChildItem -Path $dirPath -Recurse -File | Select-Object FullName, DirectoryName, Name, Extension, Length, LastAccessTime, LastWriteTime | Export-Csv -Encoding Default $exportFile

フォルダ毎のサイズ取得する(Excelで分析する)

往々にしてフォルダ毎のサイズを知りたくなる。
その場合は以下を実施する。

  1. ひとまずExcelで結果を開く
  2. B列にフォルダが一覧で出力されるので、重複を削除し、I列あたりに記入する
  3. J2列に以下を入力し、J10までセルをコピーする(10行出力されている場合で記載している)
=SUMIF($B$2:$B$10,$I2,$E$2:$E$10)

フォルダ毎のサイズが分かるので便利。

感想

PowerShellでフォルダ毎のサイズを取得することも可能ですが、分析していく上でPowerShellだけでやるよりは、Excelで分析したいときがある。

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?