46

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

3
  • Never done it myself so commenting rather than answering, most notable torrent client have this feature on gui section and some of them have command line interface. You may give a shot at transmission-cli or qbittorrent-nox or deluge-console or rtorrent. Mar 25, 2011 at 21:02
  • 2
    rtorrent doesn't have torrent creation sadly (the one I use) i'll check out the others
    – allenskd
    Mar 25, 2011 at 22:21
  • 2
    rtorrent doesn't and won't have creation feature as developer says here: libtorrent.rakshasa.no/ticket/656
    – Pedram
    Mar 25, 2011 at 22:29

5 Answers 5

41

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.

5
34

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

2
  • 1
    Note that transmission seems unable to create a Torrent file with Webseeds. Jun 27, 2017 at 7:24
  • Can be installed using the transmission-cli package in Ubuntu
    – Derkades
    Nov 7, 2022 at 19:04
3

Buildtorrent

sudo apt-get install buildtorrent

From synaptic:

Description: command line torrent creation program

buildtorrent is a torrent file creation program. Given an announce url and an input file or directory, buildtorrent generates an output .torrent file that can be used by torrent clients.

2
3

py3createtorrent

Description:

Create torrents via command line!

py3createtorrent is a comprehensive shell/commandline utility for creating torrents (Linux & Windows). It's a GPL-licensed Python v3.1 script.

3
  • Your link 404s :( Jun 27, 2017 at 7:24
  • @FrederickNord I updated the link.
    – robert
    Jun 27, 2017 at 11:14
  • FTR: It seems to be unable to create a Torrent file with Webseeds Jun 27, 2017 at 11:20
0

You can use torrenttools.

sudo add-apt-repository ppa:fbdtemme/torrenttools
sudo apt-get update
sudo apt install torrenttools
Create BitTorrent metafiles.
Usage: torrenttools create [OPTIONS] target

Positionals:
  target <path>                    Target filename or directory

Options:
  -h,--help                        Print this help message and exit
  -v,--protocol <protocol>         Set the bittorrent protocol to use.
                                   Options are 1, 2 or hybrid. [default: 1]
  -o,--output <path>               Set the filename and/or output directory of the created file.
                                   [default: <name>.torrent]
                                   Use a path with trailing slash to only set the output directory.
  -a,--announce <url>...           Add one or multiple announces urls.
                                   Multiple trackers will be added in seperate tiers by default. 
                                   Use square brackets to groups urls in a single tier:
                                   eg. "--announce url1 [url1 url2]"
  -g,--announce-group <name>...    Add the announce-urls defined from an announce group specified in the configuration file.
                                   Multiple groups can be passed. eg. "--announce-group group1 group2"
  -w,--web-seed <url>...           Add one or multiple HTTP/FTP urls as seeds.
  -d,--dht-node <host:port>...     Add one or multiple DHT nodes.
  -c,--comment <string>            Add a comment.
  -p,--private <[on|off]>          Set the private flag to disable DHT and PEX.
  -l,--piece-size <size[K|M]>      Set the piece size.
                                   When no unit is specified block size will be either 2^<n> bytes,
                                   or <n> bytes if n is larger or equal to 16384.
                                   Piece size must be a power of two in range [16K, 64M].
                                   Leave empty or set to auto to determine by total file size. [default: auto]
  -s,--source <source>             Add a source tag to facilitate cross-seeding.
  -n,--name <name>                 Set the name of the torrent. This changes the filename for single file torrents 
                                   or the root directory name for multi-file torrents.
                                   [default: <basename of target>]
  -t,--threads <n>                 Set the number of threads to use for hashing pieces. [default: 2]
  --checksum <algorithm>...        Include a per file checksum of given algorithm.
  --no-creation-date               Do not include the creation date.
  --creation-date <ISO-8601|POSIX time>
                                   Override the value of the creation date field as ISO-8601 time or POSIX time.
                                   eg.: "2021-01-22T18:21:46+0100"
  --no-created-by                  Do not include the name and version of this program.
  --created-by <string>            Override the value of the created by field.
  --include <regex>...             Only add files matching given regex to the metafile.
  --exclude <regex>...             Do not add files matching given regex to the metafile.
  --include-hidden                 Do not skip hidden files.
  --io-block-size <size[K|M]>      The size of blocks read from storage.
                                   Must be larger or equal to the piece size.

Disclaimer: I am the author of this tool.

See the documentation for more information and examples.

3
  • 1
    You appear to be the author of the linked article. When linking to your own site or content (or content that you are affiliated with), you must disclose your affiliation in the answer in order for it not to be considered spam. Having the same text in your username as the URL or mentioning it in your profile is not considered sufficient disclosure under Stack Exchange policy. Even if you disclose affiliation to the linked resources, promoting your content repeatedly and/or needlessly could be considered to be spam. Please see How to not be a spammer
    – cigien
    Apr 15, 2021 at 15:55
  • 4
    I've added a disclaimer, sorry about that.
    – fbdtemme
    Apr 15, 2021 at 15:58
  • Fails to install on arch.
    – chovy
    Dec 30, 2022 at 15:29

You must log in to answer this question.

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