Finding and deleting zero sized files

  • Section(s): Miscellaneous
  • Published on Oct 23, 2007.
  • Last Modified on Oct 23, 2007.
  • Last Modified by MitchTulloch.
  • Rated 1 out of 5 based on 2 votes.
Cool command-line trick for finding and deleting bogus files.
A consultant told me about a problem he had heard about where an IT person restored something on their server and they ended up with thousands of bogus files that had zero file size. The IT person was wondering if there was some easy way of finding all the zero sized files and deleting them. After discussing with some colleagues, the consultant came back with this solution which he later shared with me:
  1. Open a command prompt on the server and type for /R %I in (*.*) do if "0"=="%~zI" echo del /f /q "%~fI" >> c:\zerosizefiles.bat
  2. Look through your zerosizefiles.bat file to make sure nothing important will get deleted.
  3. Run the zerosizefiles.bat file.

Pretty cool use of the command line, eh?

***

Mitch Tulloch is lead author for the Windows Vista Resource Kit from Microsoft Press, which is THE book for IT pros who want to deploy, maintain and support Windows Vista in mid- and large-sized network environments. Mitch is also the author of Introducing Windows Server 2008, the first book from Microsoft Press about the exciting new server platform. For more information on these and other books written by Mitch, see www.mtit.com.

About MitchTulloch

Mitch Tulloch was lead author for the Windows Vista Resource Kit from Microsoft Press, which is the book for IT pros who want to deploy, maintain and support Windows Vista in mid- and large-sized network environments. Mitch was also the author of Introducing Windows Server 2008 and technical project lead for the Microsoft Office Communications Server 2007 Resource Kit, both books also from Microsoft Press. For more information on these and other books by Mitch, see www.mtit.com .

Share this article


Article not looking right or info is missing? Let us know so that we can fix it: .


Receive all the latest articles by email!

Receive Real-Time & Monthly WindowsNetworking.com article updates in your mailbox. Enter your email below!
Click for Real-Time sample & Monthly sample

Become a WindowsNetworking.com member!

Discuss your network issues with thousands of other network administrators. Click here to join!

Community Area

Log in | Register

Readers' Choice

Which is your preferred Firewall & VPN hardware solution?