A friend has thousands of files that likely contain nothing but NULLs (ASCII 0).
(If interested, see this Super User QA to learn why).
The files range in size from 650 bytes to ~200MB (with the majority being 4-8MB).
In Windows, what's a quick way to determine which files contain only NULLs, so they can then be deleted?
If possible, using built-in Windows (7) tools is preferred.
I was thinking something like:
findstr /m /s /r ^(\x00)+$ *.*
would work to find the files consisting of only NULLs, but in testing, it doesn't return any results.
Update 1:
I experimented with this more, and found that:
findstr /m /s /r [^\x00] *
may be working to find the inverse (files that do not only contain NULLs), which can also be used to meet the goal.
But what's odd is that:
findstr /m /s /r [^\000] *
yields different results.
Because Hex 0 (\x00
in regex) = Octal 0 (\000
in regex), I would expect the same results from both commands.
This leads me to question if the results of at least one of these commands is incorrect.
Update 2:
Well, it looks like:
findstr /m /s /r [^\x00] *
may work correctly, and the fact that:
findstr /m /s /r [^\000] *
yields different results is likely yet another Microsoft bug (if they are supposed to yield different results, please correct me by explaining why those 2 commands should yield different results).
I confirmed this using the excellent cross-platform Swiss File Knife third-party tool.
Initial testing reveals the results from the SFK command:
sfk xfindbin . "/[byte not \x00]/" -names
match those of findstr /m /s /r [^\x00] *
, but not findstr /m /s /r [^\000] *
. This leads me to believe that I may have discovered yet another bug in Microsoft's findstr
command (see SS64 for a summary of other bugs in that Microsoft tool).
Update 3:
Further testing reveals the results from the SFK command:
sfk xfindbin . "/[byte not \x00]/" -names
correctly finds some files not found by findstr /m /s /r [^\x00] *
and findstr /m /s /r [^\000] *
.