#format text_markdown ワンライナー集 ============== Windows 10 でディレクトリ容量を計算する --------------------------------------- ###ワンライナー PowerShell を使う。 ```console $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?](https://superuser.com/questions/837016/how-can-i-check-the-size-of-a-folder-from-the-windows-command-line) ###ループで回して監視する 次のようなファイルを PowerShell スクリプト (.ps1) として保存して実行。 監視のためにタイムスタンプを入れてある。CTRL+C で止めるまで 1 秒毎にタイムスタンプとディレクトリのサイズを出力し続ける。 ```bash for (;1;) { sleep 1 $totalsize=[long]0; gci -File -r -fo -ea Silent|%{$totalsize+=$_.Length}; $(Get-Date -format G)+" "+$totalsize } ``` これを tee に入れるなどするとログが取れる。 ``` PS > .\dirsize.ps1 | tee-object -file output.txt ``` 実行結果 ``` 2021/04/11 22:14:44 1716722748 2021/04/11 22:14:45 1716722748 2021/04/11 22:14:46 1716722748 ```