What Windows command to check the filenames for 0 size and delete the files

Posted on 2014-03-07
Medium Priority
Last Modified: 2014-03-17

I am looking for command  (internal or external) to write a simple batch file to see if a file has 0 byte size and to delete it.  Any help is appreciated!!

Question by:kyleshire
LVL 58

Expert Comment

ID: 39912920

On vista/win7/8/8.1 you have forfiles.exe built-in. It knows the @fsize filter which will serve your need.
LVL 14

Expert Comment

by:Zac Harris
ID: 39912924
Try this out and see if it works for you....

@echo off
call :deleteIfEmpty "yourFileName"
exit /b

if %~z1 eq 0 del %1
exit /b

Open in new window

LVL 13

Accepted Solution

Santosh Gupta earned 1500 total points
ID: 39913344
try this

for %F in (*) do if %~zF equ 0 del "%F"

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

In today’s time where quality is an essential factor all over the world, software testing and effective QA (Quality Assurance) is an all-important element for any business to ensure less risk for an end product. A good software testing company deliv…
In this article, we will show how to detach and attach a database and then show how to repair a corrupt database and attach it, If it has some errors. We will show how to detach and attach using SSMS or using T-SQL sentences.
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

600 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question