For example, do you want to search a particular folder or a whole drive? What about subfolders? If subfolders are to be searched, what is to be done with duplicate named files,Ī more complete description of the intended outcome might be useful in formulating a response (see "How to ask questions in a technical forum" ).īut, going on the fundamentals of your question, here is a starting point off That's not much of a description of what you hope to accomplish. Is stopped short, the output file will contain the results up to the point the procedure was aborted. Otherwise, it still searches from the current active folder down.
![delete zero byte files bat delete zero byte files bat](https://imagej.net/media/scripting/process-folder-ij1.png)
Set out="C:\somefolder\somewhere\zerofiles.txt"įor /r "%~1." %%A in (*.*) do if %%~zA EQU 0 echo %%~fA > %out%Ĭalled with a command line argument of "\" will cause the search to be referenced to the root of the current drive. Here is another approach that provides output as it goes, so that it So it may appear that nothing is happening.
![delete zero byte files bat delete zero byte files bat](https://www.winhelponline.com/blog/wp-content/uploads/2019/05/find-empty-files-folders-3.png)
![delete zero byte files bat delete zero byte files bat](https://www.winhelponline.com/blog/wp-content/uploads/2019/05/del-0-byte-files-script-output.png)
Wait - I think I know the problem! The search of a whole drive using the approach in the batch can take a very, very long time. To search the whole drive, either place the procedure at the root of the drive or run it from the command prompt with "C:\" (or D:\ or X:\, etc.) as the command line argument. Are you running it at a command prompt and providing an input location as a command line input? Without the input (say when double clicked in explorer), it will just search the folder in which the procedure is located (and any subfolders, if present).