Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 345
  • Last Modified:

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!
0
kyleshire
Asked:
kyleshire
1 Solution
 
McKnifeCommented:
Hi.

On vista/win7/8/8.1 you have forfiles.exe built-in. It knows the @fsize filter which will serve your need.
0
 
Zac HarrisSystems Administrator Commented:
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

0
 
Santosh GuptaCommented:
try this

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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now