a stray sheep

お仕事周りの雑記帳

Windowsでダミーファイルを扱う

ダミーファイルの作成

> fsutil file createnew testfile 1073741824
  • fsutilの実行には、コマンドプロンプトを管理者権限で起動する必要がある。※PowerShellも同様。
  • testfile 作成するダミーファイルの名前
  • ファイルサイズの単位はバイト。1073741824 バイト = 1GB

ダミーファイルを大量に作成

> for /L %%i in (1,1,10000) do fsutil file createnew testfile_%%i.dat 1073741824

ダミーファイルを作って、ファイルをコピーする。また、タイムスタンプの追加、ログの出力を行うバッチ

[test.bat]

setlocal enabledelayedexpansion
echo "開始時間: !time!" >> test.log
for /L %%i in (1,1,10000) do echo !time! >> test.log & fsutil file createnew testfile_%%i.dat 1024 >> test.log & copy testfile_%%i.dat .\targetDir >> test.log
echo "終了時間: !time!" >> test.log
endlocal
  • 複数のコマンドは、「&」でつなぐ。
  • タイムスタンプの出力のために、遅延環境変数を使う。

実行

> .\test.bat > nul