Link to home
Start Free TrialLog in
Avatar of kyleshire
kyleshire

asked on

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

Hi,

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!!

Thanks!
Avatar of McKnife
McKnife
Flag of Germany image

Hi.

On vista/win7/8/8.1 you have forfiles.exe built-in. It knows the @fsize filter which will serve your need.
Try this out and see if it works for you....

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

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

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Santosh Gupta
Santosh Gupta

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial