C:\_G\WWW\~ELISANET\INFO\tscmd076.html
<http://www.elisanet.fi/tsalmi/info/tscmd076.html>
Copyright © 2003- by Prof. Timo Salmi  
Last modified Mon 20-Jan-2020 10:15:49

 
Assorted NT/2000/XP/.. CMD.EXE Script Tricks
From the html version of the tscmd.zip 1cmdfaq.txt file
To the Description and the Index
 

This page is edited from the 1cmdfaq.txt faq-file contained in my tscmd.zip command line interface (CLI) collection. That zipped file has much additional material, including a number of detached .cmd script files. It is recommended that you also get the zipped version as a companion.

Please see "The Description and the Index page" for the conditions of usage and other such information.



76} How do I create an empty file? How can I detect the empty files?

Creating an empty file:
  if not exist empty.txt copy nul empty.txt
or (which also works in Windows 10)
  set /p=""<nul>empty.txt

Detecting empty files in a folder:
  @echo off & setlocal enableextensions
  for %%f in ("C:\_D\TEST\*.*") do (
    if %%~zf EQU 0 echo %%~tf %%~zf "%%~ff"
    )
  endlocal & goto :EOF

The output could be e.g.
  C:\_D\TEST>cmdfaq
  09.06.2008 16:26 0 "C:\_D\TEST\empty.txt"

And throughout an entire drive
  @echo off & setlocal enableextensions
  for /f "tokens=*" %%f in ('dir /b/s/a-d "d:\*.*"') do (
    if %%~zf EQU 0 echo %%~tf %%~zf %%~ff
    )
  endlocal & goto :EOF

Of course one could easily test for any particular size or range of sizes. For example, are there files that are at least a megabyte in size?
  @echo off & setlocal enableextensions
  for /f "tokens=*" %%f in ('dir /b/s/a-d "c:\*.*"') do (
    if %%~zf GEQ 1048576 echo %%~tf %%~zf %%~ff)
  endlocal & goto :EOF

Finding empty folders is covered in item #57.



[Previous] [Next]

C:\_G\WWW\~ELISANET\INFO\tscmd076.html
C:\_G\WWW\~ELISANET\FTPCMD\TSALMI.CMD /tscmd076
http://www.elisanet.fi/tsalmi/info/tscmd076.html
file:///c:/_g/www/~elisanet/info/tscmd076.html