Solved

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

Posted on 2014-03-07
3
295 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
3 Comments
 
LVL 53

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

#Citrix #POC #XenDesktop #vCenter #VMware #ESX
I use more than 1 computer in my office for various reasons. Multiple keyboards and mice take up more than just extra space, they make working a little more complicated. Using one mouse and keyboard for all of my computers makes life easier. This co…
This video shows how use content aware, what it’s used for, and when to use it over other tools.
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

706 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now