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:
- Open an elevated command prompt.
- Search for "Command Prompt" in the Windows search bar.
- Right-click on "Command Prompt" and select "Run as administrator."
- Type or copy-paste the following command:
fsutil file createnew <filename> <length>
- Substitute the
<filename>
portion with the actual name you want to give your new file.- For example,
testfile.txt
ormyfile.bin
. You can also include a path likeC:\Temp\largefile.dat
.
- For example,
- 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 thefsutil
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 theC:\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.