Page 1 of 1

How to create empty dummy files

How to create empty dummy files
   1

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 … 

Support Us ...


Your support is very much appreciated, and can be as easy as sharing a link to my website with others, or on social media.

Support can also be done by sponsoring me, and even that can be free (e.g. shop at Amazon).
Any funds received from your support will be used for web-hosting expenses, project hardware and software, coffee, etc.

Thank you very much for those that have shown support already!
It's truly amazing to see that folks like my articles and small applications.

Please note that clicking affiliate links, like the ones from Amazon, may result in a small commission for us - which we highly appreciate as well.

Comments


There is only one comment, you can read it below.
You can post your own comments by using the form below, or reply to existing comments by using the "Reply" button.

  • Dec 7, 2019 - 5:48 AM Comment Link
    PingBack: www.tweaking4all.com

    […] with names you made up. I’ve written for that purpose an article that shows you how you can make empty dummy files. Obviously FFprobe will not detect any media info, as there is none, but at least you can try and […]



Your Comment …

Do 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.