Solved

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

Posted on 2014-03-07
3
322 Views
Last Modified: 2014-03-17
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
Comment
Question by:kyleshire
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 55

Expert Comment

by:McKnife
ID: 39912920
Hi.

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

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

Open in new window

0
 
LVL 13

Accepted Solution

by:
Santosh Gupta earned 500 total points
ID: 39913344
try this

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

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This guide will walk you through the essential considerations and tech stack for building scalable websites. Know how to grow your business the smart way!
This article was originally published on Monitis Blog, you can check it here . If you have responsibility for software in production, I bet you’d like to know more about it. I don’t mean that you’d like an extra peek into the bowels of the sourc…
XMind Plus helps organize all details/aspects of any project from large to small in an orderly and concise manner. If you are working on a complex project, use this micro tutorial to show you how to make a basic flow chart. The software is free when…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

691 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