Creating files of a predetermined size

In order to test FTP file transfers across a newly installed network connection, I needed to create some files of a predetermined size (e.g. 512Kb). The easiest method I found was to run a command that writes out six characters each time it loops (plus two more bytes – a carriage return and a line feed):

@FOR /L %x IN (1,8,524288) DO @echo xxxxxx>>512kb.txt

This increments a counter by 8 each time it loops starting at 1 and ending at 524288, appending to a file called 512kb.txt. To change the file size, change 524288 to another number (divisible by 8) and the output filename to something more suitable.

One thought on “Creating files of a predetermined size

Leave a Reply