How to create a .torrent using the command line?

I'm using mktorrent, but I'm having problems with it since it doesn't hash the files in the directory for some weird reason...

I'm looking for a replacement specifically for command line


How about ctorrent?

sudo apt-get install ctorrent
ctorrent -t -u "http://tracker.example.com:6969/announce" -s example.torrent file_or_dir_to_upload 

It's also a very good client.


Transmission can do it:

$ ./transmission-create --help
Usage: transmission-create [options] <file|directory>

Options:

 -h --help              Display this help page and exit
 -p --private           Allow this torrent to only be used with the specified tracker(s)
 -o --outfile <file>    Save the generated .torrent to this filename
 -c --comment <comment> Add a comment
 -t --tracker <url>     Add a tracker's announce URL
 -V --version           Show version number and exit

an example could be:

transmission-create -o /var/lib/transmission-daemon/downloads/files.torrent -c "My comments" -t udp://tracker.openbittorrent.com:80 ~/torrent/complete/my_file_or_directory_to_share.extension

you can find more documentation here