zaro

How Do I Make a File a Certain Size?

Published in Create File Size Windows 2 mins read

You can make a file a certain size using the fsutil file createnew command in Windows.

To create a file of a specific size on Windows, you can use the built-in fsutil command-line utility. This tool allows you to manage various aspects of file systems, including creating files of a predefined length.

Steps to Create a File of a Specific Size

The process involves opening a command prompt with administrative privileges and executing a specific command.

Here are the steps:

  1. Open an elevated command prompt.
    • Search for "Command Prompt" in the Windows search bar.
    • Right-click on "Command Prompt" and select "Run as administrator."
  2. Type or copy-paste the following command:
    • fsutil file createnew <filename> <length>
  3. Substitute the <filename> portion with the actual name you want to give your new file.
    • For example, testfile.txt or myfile.bin. You can also include a path like C:\Temp\largefile.dat.
  4. Substitute <length> with the desired file size in BYTES.
    • Remember that 1 KB is 1024 bytes, 1 MB is 1024 1024 bytes (1,048,576 bytes), and 1 GB is 1024 1024 * 1024 bytes (1,073,741,824 bytes).

Understanding the Command

The command fsutil file createnew is specifically designed to create a file of a specified size, filling it with zeroes.

  • fsutil file: This specifies that you are using the fsutil command for file-related operations.
  • createnew: This is the subcommand used to create a new file.
  • <filename>: This is the placeholder for the path and name of the file you want to create.
  • <length>: This is the placeholder for the exact size of the file in bytes.

Practical Examples

Here are a couple of examples demonstrating how to use the command:

  • To create a file named dummy.txt with a size of 1024 bytes (1 KB) in the current directory:
    fsutil file createnew dummy.txt 1024
  • To create a file named bigfile.bin with a size of 50 MB (50 1024 1024 bytes) in the C:\Test directory:
    fsutil file createnew C:\Test\bigfile.bin 52428800

    (Note: 50 1024 1024 = 52,428,800)

Using this command is a quick and efficient way to generate files of arbitrary sizes for testing purposes, such as checking disk space, testing file transfer speeds, or verifying application behavior with large files.