≡ Menu

Find files with zero size

This post explains how to find all files with zero size from windows command prompt.

Find files with zero size

forfiles /S /M * /C "cmd /c if @fsize EQU 0 echo @path"
  1. If you just want to print the file name and do not need the full path, you can use @file in the place of @path.
  2. You can restrict the files selection to a certain type. If we need to do only for log files, you can use *.log with /M option. Example below.
    forfiles /S /M *.log /C "cmd /c if @fsize EQU 0 echo @path"

Delete zero sized files

The below command would delete all zero sized files, provided the user has permissions to do so.

forfiles /S /M * /C "cmd /c if @fsize EQU 0 del @path"

Be sure to check the file list once with the echo command above.

We can even search for files with size less than certain value. For example, to find all files with less than 1KB size, the command would be

forfiles /S /M * /C "cmd /c if @fsize LSS 1024 echo @path"

You might also want to read

{ 2 comments… add one }
  • MazterGee

    Thanks for sharing this useful command line tip

  • David Bethke

    I tried the “Find files with zero size” version, and it’s finding all the Folder names, as well as any “Desktop.ini” files, which are small, but not Zero Bytes.

Leave a Comment