|
サイズ: 1239
コメント:
|
サイズ: 1182
コメント:
|
| 削除された箇所はこのように表示されます。 | 追加された箇所はこのように表示されます。 |
| 行 19: | 行 19: |
| 次のようなファイルを PowerShell スクリプト (.ps1) として保存して実行。 | |
| 行 25: | 行 24: |
| $totalsize=[long]0; gci -File -r -fo -ea Silent|%{$totalsize+=$_.Length}; |
$totalsize=[long]0 gci -File -r -fo -ea Silent|%{$totalsize+=$_.Length} |
| 行 30: | 行 29: |
| これを tee に入れるなどするとログが取れる。 | 最後の出力部分を tee に入れるなどするとログが取れる。 |
| 行 32: | 行 31: |
| ``` PS > .\dirsize.ps1 | tee-object -file output.txt |
```bash $(Get-Date -format G)+" "+$totalsize | tee-object -file dirsize.txt |
ワンライナー集
Windows 10 でディレクトリ容量を計算する
ワンライナー
PowerShell を使う。
$totalsize=[long]0;gci -File -r -fo -ea Silent|%{$totalsize+=$_.Length};$totalsize
ソース: How can I check the size of a folder from the Windows command line?
ループで回して監視する
監視のためにタイムスタンプを入れてある。CTRL+C で止めるまで 1 秒毎にタイムスタンプとディレクトリのサイズを出力し続ける。
for (;1;) {
sleep 1
$totalsize=[long]0
gci -File -r -fo -ea Silent|%{$totalsize+=$_.Length}
$(Get-Date -format G)+" "+$totalsize
}
最後の出力部分を tee に入れるなどするとログが取れる。
$(Get-Date -format G)+" "+$totalsize | tee-object -file dirsize.txt
実行結果
2021/04/11 22:14:44 1716722748
2021/04/11 22:14:45 1716722748
2021/04/11 22:14:46 1716722748