Batch script to retrieve zero byte files

batchscripting

How to retrieve zero byte files and copy into a folder using batch script. can someone help me out.


i want the script should check the subfolders and displays the output as complete folder path in the output text file.


Operating system is WindowsXP. i would like to get the Zero byte files path and copy the path into a text file.

Best Answer

Create a batch file with the following commands:

@echo off
pushd %1
if exist *.txt for %%i in (*.txt) do if %%~zi==0 ECHO "%%i" >> list.txt
popd

This should find all the *.txt files of zero length and write the results to list.txt. Run the batch file from the directory where the files are located.

The following command would go through all the subfolders and the resulting txt file will contain full paths. @afrazier thanks for the correction.

for /r %i in (*.*) do if %~zi==0 ECHO "%i" >> list.txt