English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I don't need a windows software. Is there a DOS command to do that.
thanks

2006-06-19 09:56:15 · 3 answers · asked by Jameel 2 in Computers & Internet Programming & Design

I need a DOS solution. I know how delete files using windows. But I wanted to add a line in my batch file to do that for me.
This line will be repeated hundreds of times. I don't want to keep going back to Windows deleting files. It will take me all day.

Thanks

2006-06-19 10:47:05 · update #1

3 answers

This is possible. I'll show you how to do a directory listing of all zero byte files first, since that will be safe to run as a test and to see how it works.

dir /a-d /s | find " 0 "

Here's the rundown of the switches,

dir, (duh)
/a-d, shows only files (attribute NOT directory)
/s, go through subdirectories

|, this is the pipe command located on the backslash key and is very important here. It takes the output of the command to the left of it and pipes it into the command to the right of it.

find, we're going to take the output of the dir command and try to find something in the listing, mainly the number 0

" 0 ", the stuff in the quotes is the text that we're looking for. In this case, it's a carefully formatted bunch of spaces and a 0 that will only match up to files with a zero byte size. [Important NOTE at the bottom about this commandline option]

Typically a directory listing will look like,

08/04/2004 06:00 AM 80 explorer.scf
08/11/2004 06:12 PM 37 vbaddin.ini
08/04/2004 06:00 AM 2 desktop.ini
11/26/2005 11:52 AM 2 msoffice.ini
10/27/2005 11:37 PM 0 setuperr.log

I'm looking _specifically_ for the string of characters between the filedate and the filename. If I just tried to look for a zero, and deleted what I found, then I could end up deleting a bunch of important files.

So, I'm looking for exactly " 0 " which will only be matched by files with a zero byte size.

Try the dir command out without piping it through find, and make sure that your OS displays file sizes with the same format (I'm using W2K).

Then try the dir command with the pipe through the 'find' command and you should see that it lists all the files of zero bytes from where you ran it and any subdirs underneath.

Then, after you're comfortable with what it's going to do, you can replace the 'dir /a-d /s' with a 'del /s /q'

You might want to try running it in a test directory first with some test files of various sizes including zero byte files.

[IMPORTANT NOTE: when I previewed this post I noticed that Yahoo strips out some of the spaces in the 'find' command line. There should be 17 spaces before the 0 and one after it. You can always recreate the correct commandline spacing from your own dir command output.]

2006-06-28 13:20:34 · answer #1 · answered by Kevin 7 · 32 1

If they're truly "zero KB files," there is not anything to delete. If you're viewing an icon or a tree view of the files, try right clicking on the file/folder name and "delete this file." Probably the name of the file/folder is all that exists and taking up space.

2006-06-19 17:07:09 · answer #2 · answered by indiejade 2 · 0 0

Easiest way to delete a 0 kb file in windows is -
1. open a CMD prompt
2. CD to the folder where the 'file' is.
3. issue a DIR /X
4. look at the output for the files 'real' 8.3 DOS name, in the second last column.
5. use the DEL command with the 'real' 8.3 name.

Reference: http://www.tomshardware.com/forum/25641-45-trouble-deleting-file (Dans)
I found it the best and easiest solution. Someone may write a batch script around this.

2014-07-18 00:08:59 · answer #3 · answered by Manu 1 · 0 0

fedest.com, questions and answers