4

Are there any programs that can help identify files and directories belonging to unfinished bittorrent-downloads? I've made a mess, and I'm unsure of which downloads are finished and which are not. I could obviously use the bt-client, if I still had the torrent-files, but I don't. I'm therefor looking for way to identify likely unfinished bt-downloads - doesn't have to be 100% accurate.

I've noticed that bt-clients typically create empty-files, as well as leave files with "holes" (blocks of the file with just NULL-characters), so this could perhaps be a good way to find likely candidates. Sadly, I don't know any good Linux-commands for finding files with blocks of NULLs...

1
  • It'd be a good idea to add name/version of your client.
    – pyroscope
    Commented Apr 25, 2013 at 18:01

1 Answer 1

4

If your grep supports it; you could do a check by grep.

grep -P '\x00{NNN}' File

Where NNN is how many continuously zero bytes you want to match. Would typically be max USHRT_MAX or 65535.

-P is needed to use \x00

To list offsets use:

grep -Pboa '\x00{NNN}' File

So something in the direction of:

for f in *; do
    [ -e "$f" ] || break
    if grep -Pq '\x00{1000}' "$f"; then 
        mv "$f" ../likely_corrupt
    fi
done

Else you could use hexdump, xxd or the like and match for 000....

hexdump -ve '/1 "%02X"'

But that would be crazy slow.


Finally a very short C program could do the same.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .