Page 1 of 1

How to create empty dummy files

How to create empty dummy files
   0

Sometimes we need one, a few, or a lot of empty dummy files – just for testing our application, or to hold a space.

Now you could open a text editor and save an empty file, but there are easier ways to make empty dummy files.

In this article I’ll show you how it can be done under Windows (incl. DOS and PowerShell), Linux and macOS.




Empty dummy files

Let’s be clear from the start that the files we are going to create here are truly empty. Empty as in zero bytes. Totally empty.

Warning – These will be Totally Empty Dummy files! 

Since these empty files have zero content, certain additional data that certain applications expect in a file, will not be there either.

For example:
Quite a few application (for example Microsoft Word, Microsoft Excel, Adobe Photoshop, Adobe PDF, etc.) store additional data/information in their files, quite often not visible to the regular user. Ever wondered why a tiny text in Word can takes several Kilobytes (or even worse) in a .doc or .docx file?

The files that we create here will not have this additional information included. It’s really totally empty!
This means that these empty dummy files will may trigger an error message when trying to open it with one of these applications.
Simple applications like Notepad do not store extra data, and therefor will not show an error.

Below you’ll find the tricks for Linux like systems (Linux, FreeBSD, Unix and macOS) and Microsoft Windows (MSDos and PowerShell).

Linux (and most Linux variants)

Linux (and most Linux like variants) have a shell command called “touch“. To create an empty file, simply use that.

To get into the shell, from a graphical user interface, you can quite often use an application called “Shell” or “Terminal“.
Ubuntu calls it Terminal others may call it “Shell” or “Command-line”.

The example below creates the empty file example.txt:


touch example.txt

MacOS X

Since macOS has roots in FreeBSD, it should not come as a surprise that the Linux trick works here as well.
You’ll find “Terminal” under “Application” – “Utilities“.

The example below creates the empty file example.txt:


touch example.txt

Windows Desktop

From within Windows, right-click in the area where you want to create the file.
For example, right-click on the Desktop to create a new text file on the Desktop. In the drop-down menu that appears, select “New” and choose “Text Document“.

Windows - Create New Document

Windows – Create New Document

Since Windows provides access to MS-DOS, and newer Windows version also provide access to PowerShell, consider the following options as well.

Windows MS-DOS (Command or Cmd)

Here 3 examples of how this can be done in MS-DOS (or Windows Command Prompt -> press   + R, type “cmd” and press Enter – if “cmd” does not work, try “command”):


type nul >EmptyFile1.txt

REM. >EmptyFile2.txt

break > EmptyFile3.txt

Running all these results in:


C:\Users\Hans\SomeTestFolder>dir

Volume in drive C has no label.
Volume Serial Number is 28BF-AD86

Directory of C:\Users\Hans\SomeTestFolder

08/24/2018 10:50 AM <DIR> .
08/24/2018 10:50 AM <DIR> ..
08/24/2018 10:47 AM 0 EmptyFile1.txt
08/24/2018 10:47 AM 0 EmptyFile2.txt
08/24/2018 10:48 AM 0 EmptyFile3.txt
3 File(s) 2,340,236 bytes
2 Dir(s) 26,341,277,696 bytes free

Windows PowerShell

With the arrival of PowerShell (press  + R, type “powershell” and press Enter) under Windows, I had hoped the Linux trick would work, but it doesn’t – no “touch” to be found anywhere. Even worse … the good old DOS tricks didn’t work either.
After some searching I did find this trick:


New-Item test.txt

I suppose the “official ” notation would be this:


New-Item test.txt -ItemType file

But … it works just fine without the additional “-ItemType file“.

Hope this is helpful … 

Donation options


Donations are very much appreciated, but not required. Donations will be used for web-hosting expenses, project hardware or a motivational boost (a drink or snack). Thank you very much for those have donated already! It's truly AwEsOmE to see that folks like our articles and small applications.

Comments


There are no comments yet.
You can post your own comments by using the form below, or reply to existing comments by using the "Reply" button.



Your Comment …

Friendly request to not post large files here (like source codes, log files or config files). Please use the Forum for that purpose.

Please share:
*
*
Notify me about new comments (email).
       You can also use your RSS reader to track comments.


Tweaking4All uses the free Gravatar service for Avatar display.
Tweaking4All will never share your email address with others.