Deleting 0 size files

  • Thread starter Thread starter Arnold
  • Start date Start date
A

Arnold

How can I delete a 0 size file from the command prompt?
(The name can is different every day and I want to run a
script to clean it up)
 
How can I delete a 0 size file from the command prompt?
(The name can is different every day and I want to run a
script to clean it up)


Assuming the folder is called C:\Folder

Using FileSize from tip 5725 in the 'Tips & Tricks' at http://www.jsiinc.com


@echo off
setlocal
pushd C:\folder
for /f "Tokens=*" %%f in ('dir /a /a-d /b') do (
call :test "%%f"
)
popd
endlocal
goto :EOF
:test
set file=%1
call FileSize %file% size
if %size% NEQ 0 goto :EOF
del /q /f %file%

Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 
Jerold said:
Assuming the folder is called C:\Folder

Using FileSize from tip 5725 in the 'Tips & Tricks' at http://www.jsiinc.com


@echo off
setlocal
pushd C:\folder
for /f "Tokens=*" %%f in ('dir /a /a-d /b') do (
call :test "%%f"
)
popd
endlocal
goto :EOF
:test
set file=%1
call FileSize %file% size
if %size% NEQ 0 goto :EOF
del /q /f %file%

Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
Very interesting tip. But,what about the wisdom of deleting zero length
files? I seem to remember - back in Dos and Win 3.1 times - that some
programs relied on zero length files for a variety of purposes. Is it
safe now to assume that such files are just space wasters?

Regards
 
Back
Top