corrupt files full of nulls (0x20 or 0x00) but file size is correct

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
rocko8888
Junior Member
Junior Member
Posts: 2
Joined: 2018-12-12, 21:20 UTC

corrupt files full of nulls (0x20 or 0x00) but file size is correct

Post by *rocko8888 »

Hi, I have struggled with this for a few days now and have finally succumbed to posting...I have many many files (greater than 5000) in various directories that are corrupt. Long story. The thing is, these files are full of null/blank chars - of either 0x20 or 0x00 - no other chars - and the file size is retained as per original. Is there a way I can search for these types of files so that i can delete them?

I have tried regex but I get very mixed results - my tech ability is limited so any help is greatly appreciated.
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Re: corrupt files full of nulls (0x20 or 0x00) but file size is correct

Post by *MVV »

You can search for multiple spaces with regex, or it would be even faster to find files not containing space w/o regex, but you can't search for nulls with TC. So you may need some kind of script.

E.g. you make a list of such files (strictly speaking, this will find any non-zero sized files that contain bytes except 0x00 and 0x20) with PowerShell (just use destination list file outside of directory to be searched to avoid file read error):

Code: Select all

ls "X:\PathToDirWithFiles" -Recurse | ? { $_.Length -gt 0 } | % { $_.FullName } | ? { foreach ($d in [IO.File]::ReadAllBytes($_)) { if ($d -ne 0 -and $d -ne 0x20) { return 0 } }; return 1 } > D:\list.txt
Then you can feed these files to TC panel using Find Files dialog with @D:\list.txt in the 'Search in' field and then Feed to listbox button.
rocko8888
Junior Member
Junior Member
Posts: 2
Joined: 2018-12-12, 21:20 UTC

Re: corrupt files full of nulls (0x20 or 0x00) but file size is correct

Post by *rocko8888 »

Excellent!! Saved my a...thank you...
Post Reply