Welcome to TSG!
Robocopy won't let you specify a max size of zero, it has to be at least 1, which will also copy/move 1 byte files.
If that will work, this will move all files size 0 or 1, then delete them:
Code:
Set _Source=C:\My Folder
Set _Dest=C:\My Temp
Robocopy "%_Source%" "%_Dest%" /Max:1 /MOV
Del %_Dest%\*.* /Q
Otherwise you can use a For loop and Dir to Delete the files with a 0 byte size. I've put an
Echo statement in front of the Del command for testing, remove it when you are satisfied it will delete only what you want deleted:
Code:
@Echo Off
Set _Source=C:\My Folder
PushD "%_Source%"
For /F "tokens=*" %%A In ('Dir /OS /A-D /B') Do If %%~zA==0 Echo Del %%A
PopD
This next version will exit after processing the 0 byte files, so may be faster. May not get them all though.
Because of the way a For loop works, you could get a Dir that sees a file as zero bytes because it was just created, but by the time it's size gets checked by the If statement, it's no longer 0, so the loop would end before all the 0 byte files were deleted.
Some system files may show as zero even when they aren't as well.
If you run this in the Windows folder, Dir sees the
wiaservc.log as a zero byte file, but it's actually 49 bytes on my system. So out of 6 zero byte files, it only deletes 2 files.
Code:
@Echo Off
Set _Source=C:\My Folder
PushD "%_Source%"
For /F "tokens=*" %%A In ('Dir /OS /A-D /B') Do (
If %%~zA GTR 0 (
Goto :_Done
) Else (
Echo Del %%A
))
:_Done
PopD