I was recently performing some performance testing that required me to copy many files of a particular size from one Windows XP workstation to a Windows 2003 server. I had a heck of a time figuring out how to batch generate the test files.
Finally I cam across the fsutil tool, which is included on both Windows XP and Windows Server 2003.
The syntax for using fsutil is:
fsutil file createnew filename filesize
I used a simple loop to create files of a particular size using fsutil. Running from a command prompt:
For /L %i in (1,1,25000) do fsutil file createnew A%i.tmp 12288
will create 25,000 files of 12288 bytes (12KB) named A1.tmp, A2.tmp, A3,tmp…
to run this loop in a .cmd file instead of from the command line replace single % with double percent signs
For /L %i in (1,1,10000) do fsutil file createnew B%i.tmp 65536
will create 10,000 files of 65536 bytes (64KB) named B1.tmp, B2.tmp, B3,tmp…
For /L %i in (1,1,2500) do fsutil file createnew C%i.tmp 131072
will create 2,500 files of 131072 bytes (128KB) named C1.tmp, C2.tmp, C3,tmp…
For /L %i in (1,1,1000) do fsutil file createnew D%i.tmp 1048576
will create 1,000 files of 1048576 bytes (1024KB or 1MB) named D1.tmp, D2.tmp, D3,tmp…
I was able to create hundreds of thousands of files of a very specific size in a short amount of time using this procedure.
{ 5 comments… read them below or add one }
Thank you! Worked like a charm…just FYI small typo on fsutil (fstuil)
Good catch Ryan. That was a case of my dyslexia surfacing. I’ve updated the posting with the correct spelling.
-Julie
This is a good approach, that helped me in practice! I needed a file generator, and I’ve been using your solution for a while.
But the local peculiarity of is that it creates binary files filled up with zeros. That’s a disadvantage for benchmarking, cos fsutil cannot simulate a real-world environment.
I’ve just implemented a filegen.exe, which generates random files.
Man! Thank you! Thanks for taking the time to share! I love You!
Thank you for this ! I found this very helpful. It was exactly what I needed.
{ 1 trackback }