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.

Comments

One response to “Creating files of a predetermined size”

  1. Owen Cutajar avatar
    Owen Cutajar

    Very cute

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.