sezzz Topic Starter
Posts: 3
|
 |
« on: November 15, 2009, 08:45:04 PM » |
|
Hai all, is any bat file option to get all the file with zero size capacity in each drive in winxp drive so that these zero size files has to delete
please help me.
|
|
|
|
|
gh0std0g74
Thanked: 37 Posts: 590
|
 |
« Reply #1 on: November 15, 2009, 09:14:20 PM » |
|
see here for vbscript solution. the other easier method, if you can afford to, is to use GNU find. (see my sig to download). c:\test> gnu_find.exe c:\test -type f -size 0 -delete
Of course, if you want to use a pure cmd.exe solution, use a for loop with dir, then use %~zI . see for /? for more info. OR search this forum.
|
|
|
|
billrich Guest
|
 |
« Reply #2 on: November 19, 2009, 09:07:59 AM » |
|
C:\batch>type empty2.bat @echo off
dir /x *.* | find " 0 " > zerotxt.txt
for /f "tokens=5 delims= " %%i in (zerotxt.txt) do ECHO "%%i"
rem for /f "tokens=5 delims= " %%i in (zerotxt.txt) do del /F "%%i"
rem remove the rem from above when satisfied list is correctC:\batch>
Warning: Be very careful with search and delete from root down: /s cd \ dir /X / s *.* | find " 0 " > zerotxt.txt
|
|
|
|
« Last Edit: November 19, 2009, 12:04:08 PM by billrich »
|
IP logged
|
|
|
|
|
|
billrich Guest
|
 |
« Reply #4 on: November 19, 2009, 09:47:59 AM » |
|
code will find nonzero files
S:>echo hello > "0 0 0.txt"
S:\Test>dir *.* | find " 0 " 19/11/2009 16:22 8 0 0 0.txt QED
QED = "Quite Easily Determined" Sezzz, the original poster, requested how to find files with zero bytes and how to delete the files with zero bytes.
|
|
|
|
|
|
|
billrich Guest
|
 |
« Reply #6 on: November 19, 2009, 10:33:31 AM » |
|
What about filenames with spaces?
Would "" help? for /f "tokens=5 delims= " %%i in (zerotxt.txt) do del /F "%%i" for /f "tokens=5 delims= " %%i in ("zerotxt.txt") do del /F "%%i"
|
|
|
|
|
|
|
|
|
billrich Guest
|
 |
« Reply #9 on: November 19, 2009, 11:31:29 AM » |
|
Hello
|
|
|
|
« Last Edit: November 21, 2009, 10:42:29 PM by billrich »
|
IP logged
|
|
|
|
|
|
billrich Guest
|
 |
« Reply #11 on: November 19, 2009, 11:41:42 AM » |
|
Hello
|
|
|
|
« Last Edit: November 21, 2009, 10:41:25 PM by billrich »
|
IP logged
|
|
|
|
|
|
billrich Guest
|
 |
« Reply #13 on: November 19, 2009, 12:02:47 PM » |
|
Hello
|
|
|
|
« Last Edit: November 21, 2009, 10:40:20 PM by billrich »
|
IP logged
|
|
|
|
|
|
billrich Guest
|
 |
« Reply #15 on: November 19, 2009, 01:14:33 PM » |
|
Hello
|
|
|
|
« Last Edit: November 21, 2009, 10:39:00 PM by billrich »
|
IP logged
|
|
|
|
|
|
gh0std0g74
Thanked: 37 Posts: 590
|
 |
« Reply #17 on: November 19, 2009, 05:03:36 PM » |
|
I use XP SP3 too and ('dir /b /s /a-d') worked fine. I don't know why it didn't work for you. One thing - if you scan a whole drive there may be a long time when nothing seems to be happening.
zerodel.bat
@echo off ..... for /f "delims==" %%A in ('dir /a /b /s /a-d') do ( if "%%~zA"=="0" ( set /a file+=1 echo [!file!] 0 bytes "%%~dpnxA" echo del "%%~dpnxA" >>"%temp%\deletions.bat" ) ) .....
The above method delete files one by one. Not that its really a big deal, but a suggestion for a more efficient way, since del can delete multiple files passed to it on the command line, is to concat all the filenames into one string, either by batches (or as many as del can take as input) and then pass it to del.
|
|
|
|
« Last Edit: November 19, 2009, 05:51:21 PM by gh0std0g74 »
|
IP logged
|
|
|
|
billrich Guest
|
 |
« Reply #18 on: November 20, 2009, 04:35:46 AM » |
|
Hello
|
|
|
|
« Last Edit: November 21, 2009, 10:36:14 PM by billrich »
|
IP logged
|
|
|
|