tags:

views:

502

answers:

6

Does anyone have a way to generate files of random data in Windows? I would like to generate 50,000 small (2K) files as an example.

A: 

Well, technically you could write something to do this for you.
I don't know of anything specific.. but the easiest way would be to create a TEXT file of a specific size (2K for example).. then write a batch file to copy it 50000 times.

Jon
+3  A: 

You'll have to create files in the normal way, and then populate them with randomized data, probably from a rand() function of some sort.

It really depends on your programming language. Windows itself certainly won't provide this capability.

There are a number of programming languages that could do this easily, however, including basic windows batch/CMD scripts. What language are you interested in using?

levand
+1  A: 

How about something like this: Random File Generator 1.1

Or File generator

beach
Well, if that becomes the accepted answer, then it wasn't much of a programming question.
EBGreen
+1  A: 

You can run fsutil in a batch loop to create files of any size.

fsutil file createnew filename.extension 2000
Bogdan
I just found that utility. Didn't know it existed before. http://thebackroomtech.com/2009/01/16/howto-generate-many-files-of-a-particular-size-in-windows/
beach
However, it doesn't create random data. Just blank files.
beach
A: 

Since you don't specify a language, I'll simply pick one at random. Here is a powershell script to do it:

$rootDir = 'C:\Temp\TestRandomFiles\'
$baseFile = $rootDir + "base.txt"
$desiredFileSize = 2*1KB
$fileCount = 50000
"start" | Out-File -Filepath $baseFile
While ($(Get-ChildItem -path $baseFile).Length -lt $desiredFileSize)
{
    $(Get-ChildItem -path $baseFile).Length | Out-File $baseFile -APPEND
}
for($i=1;$i -lt $fileCount;$i++)
{
    Copy-Item $baseFile "File$i.txt"
}

You'll have to change the variables to the parameters that you want of course.

EBGreen
oops...missed the random data requirement. Is that important? If so I can tweak it.
EBGreen
A: 

I have been using Random Data File Creator and liking it, it creates binary files, ie not text files filled with pseudo-random bits, it can quickly create very large files. To use it to create multiple small files you would need to script it, which would be very easy given it is command line.

David Waters