Solved

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

Posted on 2014-03-07
3
305 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 54

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows doesn't download updates 26 103
User cannot delete a folder from the desktop. 3 71
Inventory equipment in the office 7 120
Easy to use inventory management software 7 94
In this article, you will read about the trends across the human resources departments for the upcoming year. Some of them include improving employee experience, adopting new technologies, using HR software to its full extent, and integrating artifiā€¦
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 video demonstrates basic masking and how to edit the mask to reveal the desired image.
Viewers will learn how to use the Hootsuite Dashboard.

777 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