Jump to content
  • Announcement

    The HyperSpin 2 beta is here!

    We’re starting the first public testing phase with Platinum Members to keep the scope manageable while we test the current feature set and begin to add more. In the future, we’ll provide a version for basic members as well.  On behalf of the entire HyperSpin team, we look forward to another exciting adventure with our community.

How do I use torrentcheck?


KrillCaz

Recommended Posts

Posted

I'm assuming that you just want to verify a downloaded torrent with the hash(es) stored in its torrent file? Most BitTorrent clients should have an option to do this after a torrent is downloaded, but using a dedicated program is just fine too.

After you extract "torrentcheck-1.00.zip" to a folder, hold shift and right click anywhere within that folder (in the file explorer) then click "Open command window here". This should open a command prompt, starting in that directory. Alternatively, you can open a new command window by hitting Windows>R, typing "cmd" and pressing enter. However this will usually start you in your user folder - so you'll need to either change directories to the location of the torrentcheck executable or change "torrentcheck" in your command to its file path instead.

Looking at the included text file, the syntax for torrentcheck is pretty simple. Here's a portion of that file:


[indent]
torrentcheck - catalog a .torrent file and optionally verify content hashes

Usage: torrentcheck -t torrent-file [-p content-path] [-n] [-h] [-c] [-d]

Options:[indent]-n suppresses progress count
-h shows all hash values
-c or -d uses comma or dot formatted byte counts[/indent]


Returns 0 if successful, nonzero return code if errors found.

Option: -sha1 [optional hash] acts as a simple SHA1 filter.
If -sha1 is followed by a hex hash, the return code will be zero
on match and nonzero otherwise.

Summary
-------
This program is a command-line utility to catalog and verify torrent files.
Run with only the -t option, it displays the metadata, name, and size of
each file in the torrent. Run with the -t and -p options, it computes the
hashes of all files in the torrent, compares them against the hashes stored
in the metadata, and warns of any errors.

If torrentcheck returns "torrent is good" at the end of its output, every
byte of every file in the torrent is present and correct, to a high degree of
certainty as explained below.

For example, if you run torrents on a fast external server and then download
the files, this utility will verify that the files you received are complete
and uncorrupted. It can also be used to verify backups or to automatically
check a series of torrents using scripting.

The -t parameter should be the path to the .torrent metadata file. The -p path
should point to the file or files. It can include or leave out the torrent name.
The -n option suppresses the running count, which is useful if you are writing
the output to a file. The -h option shows all piece hash values. The -c or -d
options produce comma or dot formatted byte counts for readability.

The -sha1 option disables torrent checking, and instead acts as a SHA1 filter.
Most Windows machines do not have a SHA1 utility, so I included this mode as a
convenience feature. It reads in binary data from standard input until end of
file, and prints the SHA1 hash. If a SHA1 hash is provided on the command line,
it will return 0 if the hashes match or nonzero if they do not. This mode
should agree with the output of "openssl dgst -sha1" or "digest -a sha1"

Examples
--------
torrentcheck -t \torrents\ubuntu-10.10-desktop-i386.iso.torrent
torrentcheck -t \torrents\ubuntu-10.10-desktop-i386.iso.torrent -p \download
torrentcheck -t \torrents\ubuntu-10.10-desktop-i386.iso.torrent -p \download && echo good
torrentcheck -t \torrents\ubuntu-10.10-desktop-i386.iso.torrent -p \download || echo bad
torrentcheck -t \torrents\ubuntu-10.10-desktop-i386.iso.torrent -p \download\ubuntu-10.10-desktop-i386.iso
torrentcheck -sha1 < \download\ubuntu-10.10-desktop-i386.iso
torrentcheck -sha1 b28bbd742aff85d21b9ad96bb45b67c2d133be99 < \download\ubuntu-10.10-desktop-i386.iso && echo good
(These are for Windows; use forward slashes in Unix/Linux)
[/indent]

So in short, if I wanted to verify the content of the torrent "AboutBananas" against its torrent file "AboutBan1935_archive.torrent" I'd type:

torrentcheck
-t
"C:/Users/Macklin/Downloads/AboutBan1935_archive.torrent"
-p
"C:/Users/Macklin/Downloads/AboutBananas/" -c

This tells Windows to execute torrentcheck, the executable in the current directory, providing it with the path to the torrent file (the path prefixed by the flag "-t"), the path to the file or files that the torrent contains (the path prefixed by the flag "-p"), as well as "-c" which tells the program to output comma-formatted byte counts for readability.

After pressing enter, I get the output:

Torrent file  : C:/Users/Macklin/Downloads/AboutBan1935_archive.torrent
Metadata info : 33915 bytes, 1553 pieces, 524,288 bytes per piece
Torrent name  : AboutBan1935
Content info  : 10 files, 814,202,221 bytes
Announce URL  : http://bt1.archive.org:6969/announce

F#  Ok? Bytes         File name
--- --- ------------- ---------------------------------------------------------
 1 ok     38,496,262 AboutBan1935.avi
 2 ok        259,573 AboutBan1935.gif
 3 ok    306,617,225 AboutBan1935.mpeg
 4 ok     46,417,991 AboutBan1935.ogv
 5 ok          2,161 AboutBan1935.xml
 6 ok    116,127,544 AboutBan1935_256kb.rm
 7 ok     45,941,165 AboutBan1935_512kb.mp4
 8 ok     48,764,199 AboutBan1935_64kb.rm
 9 ok    211,573,767 AboutBan1935_edit.mp4
10 ok          2,334 AboutBan1935_meta.xml
Total files 10, total bytes 814,202,221, total errors 0, torrent is good

And that tells me that all SHA1 sums line up with what was expected from the torrent file, and that the downloaded content is indeed a perfect replica of its source. I can also add the "-h" flag to see more detailed output as every piece gets computed and compared to its original file.

Too easy.

I think that anyone who uses a computer should at least know how to use basic command line programs. CLI's were the sole precursor to modern graphical computing after all!

Posted

Thank you so much for that guide! Not only did it help me with my issue, but it also gave me a better understanding of how "command-line" is used. I'm actually attempting to use torrentcheck to move my surplus roms to a different folder. Can this be done? For example, I downloaded an old PS1 redump set a while ago (ex. 20130125), and since then an updated version has been released (ex. 20141223)... I have downloaded the updated redump set and directed the torrent path to my old (existing) redump set-- which resulted in me having extra roms (slightly renamed roms/old dumps). Can torrentcheck be used to move the redundant files to a different folder, and only leave the files which are from the new set?

Posted

Hmm, I see. I'm not sure if torrentcheck will help with that. If the updated version of your romset contained every single rom plus the updated ones - you can always just do this manually. I'd just sort your roms folder by date (by clicking the "Date modified" column in the file explorer) and then delete/move the ones have an older date.

I'm going to get ahead of myself before you respond and show you a way that this can be done with the built-in Windows CLI tool "robocopy". Documentation for this program can be found here. Here's the command you'll probably need:

robocopy source destination * -s -mov -minage:30 -l

Again, the syntax here is fairly simple:

robocopy
The program that you want to run. Because robocopy.exe is a program contained in the PATH variable (the directory in which system programs are stored - usually system32), you are not required to be in the directory that it is contained. This allows you to easily run system programs from any directory.

source

The path to the source directory

destination

The path to the destination directory

*

A wildcard meaning zero or more of any character. In this case this just means any and all files in the source directory. If I wanted to move only files that started with the letter A and had the extension .jpg I would put
A*.jpg

-s

Flag which tells robocopy to act on subdirectories.

-mov

Flag which tells robocopy to move files.

-minage:X

Flag, along with the argument "X" which tells robocopy only to act on files that have a minimum age of X days.

-l

Flag which tells robocopy to only list files (rather than act on them). With -l in your command, you can do a dry run to see what will happen without actually doing it.

And now for an example!

I have the folder "my_files" on my Desktop which contains a mix of old and new files. Now I want to move all files that are older than 30 days to another directory, but I don't want to go through and compare dates and move files manually - so I can use robocopy to do this. First thing I do is make a new folder to which my older files will be moved, I'll call the folder "old_files". Next, I open a new prompt. Using cd (the change directory command - see here) I change the working directory to my desktop

cd /Users/Macklin/Desktop

To be fair, I can run robocopy from anywhere - but usually I'd go into the folder above my source directory in order to prevent me from having to type whole or partial file paths. If I wanted to see the contents of my_files, I can type:

dir my_files

Directory of C:\Users\Macklin\Desktop\my_files

30/01/2015  11:08 AM    <DIR>          .
30/01/2015  11:08 AM    <DIR>          ..
30/01/2015  09:41 AM                 0 1_new.txt
30/01/2015  09:41 AM                 0 2_new.txt
01/01/2014  09:45 AM                 0 2_old.txt
30/01/2015  09:41 AM                 0 3_new.txt
30/01/2015  09:41 AM                 0 4_new.txt
01/01/2014  09:48 AM                 0 4_old.txt
30/01/2015  09:41 AM                 0 5_new.txt
              7 File(s)              0 bytes
              2 Dir(s)  354,240,606,208 bytes free

You'll notice that I have two older files in my_files; 2_old.txt and 4_old.txt.

Next, I type the actual robocopy command in the prompt:

robocopy my_files old_files * -s -mov -minage:30 -l

After pressing enter, I'm presented with the following output:

-------------------------------------------------------------------------------
  ROBOCOPY     ::     Robust File Copy for Windows

-------------------------------------------------------------------------------

 Started : Friday, 30 January 2015 10:58:50 AM
  Source : C:\Users\Macklin\Desktop\my_files\
    Dest : C:\Users\Macklin\Desktop\old_files\

   Files : *

 Options : /L /S /DCOPY:DA /COPY:DAT /MOV /MINAGE:30 /R:1000000 /W:30

------------------------------------------------------------------------------

                          7    C:\Users\Macklin\Desktop\my_files\
           New File                   0        2_old.txt
           New File                   0        4_old.txt

------------------------------------------------------------------------------

              Total    Copied   Skipped  Mismatch    FAILED    Extras
   Dirs :         1         0         0         0         0         0
  Files :         7         2         5         0         0         0
  Bytes :         0         0         0         0         0         0
  Times :   0:00:00   0:00:00                       0:00:00   0:00:00
  Ended : Friday, 30 January 2015 10:58:51 AM

This shows a list of files/folders in the source directory that meet the criteria (older than 30 days) and that would've been moved to the destination directory. When I'm happy with the output I can run the command again without the "-l" to go ahead and move those files over to the destination. While in the command prompt, I can use my arrow keys to cycle through previously entered commands so I don't have to type the command again.

So that's pretty much it. There are of course dozens of graphical programs to do this, but why bother downloading a program to do something if you already have the means to do it?

I hope this helps or is at least relevant! Feel free to ask if you're not sure about something.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...