How to find and list zero byte files in Windows and Linux A single-line Command Prompt script that will help you to locate all zero-byte files on your Windows or Linux machine and print them on screen or file

How to execute PHP7 CLI commands with cPanel and EasyApache 4 - PHP7 CLI path

Today I was asked to write a simple batch script to locate all zero-byte files within a Windows Server machine.

The answer was definitely simple, thanks to the powerful FOR command available in cmd.exe:

Windows

This will create a list.txt file containing all the zero-byte files found within the current execution folder and all its subdirectories. If you want them on screen, simply remove the > list.txt at the end.

Linux

Since I made it for Windows, I thought it could do the same with Linux. Here’s the one-liner:

Again, if you want them on screen, remove the > list.txt at the end.

That’s about it!

 

About Ryan

IT Project Manager, Web Interface Architect and Lead Developer for many high-traffic web sites & services hosted in Italy and Europe. Since 2010 it's also a lead designer for many App and games for Android, iOS and Windows Phone mobile devices for a number of italian companies. Microsoft MVP for Development Technologies since 2018.

View all posts by Ryan

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.