In the same vein as http://stackoverflow.com/questions/257844/quickly-create-a-large-file-on-a-linux-system I'd like to quickly create a large file on a windows system. By large I'm thinking 5GB. The content doesn't matter. A built in command or short batch file would be preferable, but I'll accept an application if there are no other easy ways.
Check the windows resource kit.
There is a utility called
CREATEFIL.EXE
-? : This message
-FileName -- name of the new file
-FileSize -- size of file in KBytes, default is 1024 KBytes
It is the similar to mkfile on solaris.
Short of writing a full application, us Python
guys can achieve files of any size with 4 lines, same snippet on Windows and Linux (os.stat()
line is just a check).
>>> f = open('myfile.txt','w')
>>> f.seek(1024-1) # an example, pick any size
>>> f.write('\x00')
>>> f.close()
>>> os.stat('myfile.txt').st_size
1024L
>>>
I found a solution using DEBUG at http://www.scribd.com/doc/445750/Create-a-Huge-File, but I don't know an easy way to script it and it doesn't seem to be able to create files larger than 1 GB.
You can use the Sysinternals Contig tool. It has a -n
switch which creates a new file of a given size. It will create a file almost instantaneous.
/*
creates an empty file, which can take
all of the disk space. Just specify the desired file
size in the command line
*/
#include <windows.h>
#include <stdlib.h>
int main (int argc, char* ARGV[])
{
int size;
size = atoi(ARGV[1]);
const char* full = "fulldisk.dsk";
HANDLE hf = CreateFile(full,
GENERIC_WRITE,
0,
0,
CREATE_ALWAYS,
0,
0);
SetFilePointer(hf, size, 0, FILE_BEGIN);
SetEndOfFile(hf);
CloseHandle(hf);
return 0;
}
fsutil file createnew <filename> <length>
where <length>
is in bytes.
Blooming Big File. Google it. It quickly creates big files on Windows machines.
Hey i know this is an older thread but i was wondering if any of you would know how to make an incremental naming solution for this .bat file Leigh was working on here. for instance if you had contig -n I:\SpaceBuffer.tmp 5368709120 and you wanted to make it do a loop:
set number for (parameters) {
contig -n I:\SpaceBuffer%number%.tmp 5368709120 number++ } How would someone do this in a .bat file. I have taken intro Comp Sci classes in school but honestly i'm complete rubbish at programming and unless i've seen something hashed out for me I really can't do it.