Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating Random Files in Windows

Tags:

windows

People also ask

How do I select random files in Windows?

Click the first file or folder you want to select. Hold down the Shift key, select the last file or folder, and then let go of the Shift key. Hold down the Ctrl key and click any other file(s) or folder(s) you would like to add to those already selected.

How create 1gb file in Windows?

Open up Windows Task Manager, find the biggest process you have running right click, and click on Create dump file . This will create a file relative to the size of the process in memory in your temporary folder. You can easily create a file sized in gigabytes.


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

fsutil file createnew filename.extension 2000

I have been using Random Data File Creator and liking it, it creates binary files (i.e. 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.


You can use PowerShell to generate cheap random data for your files:

[Byte[]] $out = @()
0..2047 | % {$out += Get-Random -Minimum 0 -Maximum 255}
[System.IO.File]::WriteAllBytes("myrandomfiletest", $out)

This uses an algorithm with a seed taken from the system clock, so don't use this for ANY serious cryptographic applications.

In addition, be wary of the performance degradation of Get-Random when increasing the size of the output file. More on this aspect here:


One-liner in Powershell:

$out = new-object byte[] 1048576; (new-object Random).NextBytes($out); [IO.File]::WriteAllBytes('d:\file.bin', $out)

This is lightning fast, compared to @user188737 solution.