Creating Multiple Files, or Copies of a File

I wanted to create a number of copies of a file. I wanted to know how to do this for two separate reasons. First, occasionally I had thought that it might be useful to create enough files to fill a drive, for purposes of drive testing. Second, sometimes there would be situations where I would want many copies of exactly the same file. This post describes the former purpose in detail, and then explains how to modify it to achieve the latter.

I began by using Microsoft Excel to create batch commands that would create the files in question. I used Excel 2010, though any version or close alternative (e.g., LibreOffice) would have worked equally well. (Some programs might require slight changes of command syntax.) The batch commands would rely on the old DOS COPY command.

For purposes of creating successively larger files, thereby filling space quickly, I decided to create commands that would copy the two most recently created files into one new file — which would then become a part of the next, even larger, new file. This did not result in a doubling of file size each time, but it still scaled up pretty quickly. This approach could leave a substantial amount of unfilled space, but that space could be quickly filled by just making manual copies of a few of the already created files of the appropriate size.

I decided to begin with a plain text file containing Yogi Berra’s famous adage, “You can observe a lot by just watching.” (I admit, I was tempted to use “All work and no play makes Jack a dull boy.”) I called that file Observe00001.txt. So I would wind up with ever-larger files repeating that adage multiple times: Observe00002.txt, Observe00003.txt, and so forth, where Observe00003.txt would contain 00001 and 00002.

To create the commands that would create my multiple, ever-growing files, I set up an Excel spreadsheet like this:


Column A contained an arithmetic progression.  I took it from 1 to 100, but didn’t need to go that high for my purposes. Column B contained a sequence of file names incorporating the numbers from Column A. Column C contained a sequence of batch file commands incorporating the file names from Column B.

I knew of two ways to create Column A. One was to use a formula. So, for example, the formula in cell A2 would be =A1+1. The other was to use Edit > Insert > Series. I knew this as an Alt key sequence from older versions of Excel: put 1 in cell A1, 2 in cell A2, and then highlight cells A1 to A100 and hit Alt-E I S [Enter]. But you could also just select cells A1 and A2 and drag the bottom right corner downward.

To create Column B, I put this formula in cell B1, and then copied it all the way down:


That formula worked by repeating zero enough times to fill five places (i.e., five minus the length of the number in cell A1). I would have had to surround my file names with CHAR(34), the code for a quotation mark, if they had contained spaces (e.g., =char(34)&”File name”&char(34)).

To create Column C, I put this formula in cell C3, and copied it down:

="copy "&B1&"+"&B2&" "&B3

I had to use a manual alteration in cell C2, as shown in the image above.

Once I had Column C populated, I could copy its contents into a batch file. This meant simply opening Notepad, pasting them in there, and naming it with a BAT extension. The file name I chose was Copier.bat. Batch files would run like any other executable, so I just had to put Copier.bat into the folder containing Observe00001.txt and then select it and hit Enter (or double-click on it).

Copier.bat produced the first three dozen files pretty quickly. Then things began to bog down. Observe00035.txt was about 350MB. Observe00040 was about 3.9GB. It had taken one minute to reach Observe00035.txt on a fairly slow machine; it took another five minutes to get from there to Observe00040.txt.

To interrupt the process at any point, just hit Ctrl-C in the DOS box, or just close that box.

To modify this technique to produce many copies of Observe00001.txt, each of the same size, the commands in Column C would just have to be modified so that each would copy Observe00001.txt to be Observe00002.txt and Observe00003.txt and so forth, without combining two files together. (Hint: hit F4, when editing the reference to cell B1 in column C, to get absolute references.)

Other posts suggest other uses for batch files (e.g., to start programs on a schedule; to convert multiple Microsoft Word documents to PDF).

This entry was posted in Uncategorized and tagged , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

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