Written by
Sherry SongHave you known that you can create a file of a specific size on Mac? So interesting, right? For various needs, such as testing storage limits, simulating data environments, or ensuring file system integrity, creating files of a certain size can be essential.
There might come a time when you need to create a file of a specific size, which can help you better manage disk space. On a Mac, there are several ways to accomplish this. This article will guide you through both the most convenient way to create a new file on Mac and make files of certain sizes with built-in tools.
The fastest way to create a new file on Mac
By default, Mac's context menu only includes the option to create a "New Folder" but not the option "New file". You have to open some apps to create your needed files, too cumbersome!!!
iBoysoft MagicMenu is a convenient tool, that enhances the Mac context menu by adding a "New File" shortcut. You can easily create various types of files: DOC, DOCX, XLS, XLSX, TXT, PDF....with it from the right-click menu on your desktop or within any open folder.
With iBoysoft MagicMenu, you no longer need to open specific apps, do so many actions, or use difficult commands to create a new file, why not download and save your cherishing time?
Create files of specific size on Mac with Terminal
Now let's learn how to create files of specific size on Mac. One Tool is Mac Terminal, which is suitable for those who are comfortable with command lines. Here, we can explore three commands dd, mkfile, and truncate to make a file of a certain size on Mac.
Command dd to create files of specific size on Mac
The dd command is a powerful utility for creating files with specific sizes. You can use it to create a file of a specific size on Mac filled with zeros or random data. (Here is an example to create a file named "testfile" of 100MB filled with zeros.)
- Finder > Applications > Utilities > Terminal.
- Type dd if=/dev/zero of=~/Desktop/testfile bs=1m count=100
if=/dev/zero: Input file is zero (file filled with zeroes).
of=~/Desktop/testfile: Output file path (this creates the file on your Desktop).
bs=1m: Block size (1 megabyte).
count=100: Number of blocks (100 blocks of 1MB each = 100MB). - Press the Enter key and wait.
If you want a file with random data, replace /dev/zero with /dev/urandom.
Command mkfile to create files of specific size on Mac
The mkfile command is simpler and specifically designed for creating files of a certain size on Mac. (Here is an example to create a file named "testfile" of 100MB.)
- Finder > Applications > Utilities > Terminal.
- Type mkfile 100m ~/Desktop/testfile.
100m: File size (100 megabytes).
~/Desktop/testfile: Output file path (this creates the file on your Desktop). - Press the Enter key and wait.
Then they fail, you can try the next command.
Command turncate to create files of specific size on Mac
The truncate command can also be used to resize or create a file of a specific size. (Here is an example to create a file named “testfile” of 100MB.)
- Finder > Applications > Utilities > Terminal.
- Type truncate -s 100M ~/Desktop/testfile.
-s 100M: Set the size to 100 megabytes.
~/Desktop/testfile: Output file path (this creates the file on your Desktop). - Press the Enter key and wait.
Please share these commands to help more people~
Create files of specific size on Mac with Disk Utility
For those who prefer a graphical user interface, macOS's built-in Disk Utility can be used to create disk image files(also called .dmg files) of a specified size.
- Finder > Applications > Utilities > Disk Utility.
- File > New Image > Blank Image.
- Select the parameters one by one.
(The Partition and Image Format remain the default settings.) - Click Save to create the image file.
Note this method can only create a .dmg file of a specific size on Mac. Share this post on your social platforms.
Conclusion
Creating files of a specific size on Mac is an easy process, whether you prefer using a graphical tool or Terminal commands.
For quick new file creation, iBoysoft MagicMenu offers the fastest way. Hope you can enjoy your digital life with Mac.