How do I make a file a specific size?
Category:
technology and computing
operating systems
To create a file of specific size in Windows 10, do the following.
- Open an elevated command prompt.
- Type or copy-paste the following command: fsutil file createnew <filename> <length>
- Substitute the <filename> portion with the actual file name.
- Substitute <length> with the desired file size in BYTES.
Likewise, people ask, how do I make a file a specific size in Linux?
6 Methods to create files of specific size in Linux
- fallocate: fallocate is used to preallocate or deallocate space to a file.
- truncate: truncate is used to shrink or extend the size of a file to the specified size.
- dd: Copy a file, converting and formatting according to the operands.
Also asked, how do I create a test file?
For example, to create a 10 megabyte test file:
- Click on the 'Start' button.
- In the search box type 'cmd'
- Right-click on Command Prompt and choose 'Run as administrator'
- Enter the following command:
- fsutil file createnew C:TestFile.txt 10485760.
- The file will be located in the C: directory.
The easiest and most used method to truncate files is to use the > shell redirection operator.
Let's break down the command:
- The : colon means true and produces no output.
- The redirection operator > redirect the output of the preceding command to the given file.
- filename , the file you want to truncate.