I have a directory structure that looks like:


I would like to create a torrent using CLI utilities that contains:


(Note: this is a simplified example. In reality, there are four directories and thousands of files in each, and I would like to select ~100 files out of each directory. So solutions that involve simply excluding specific files won't work.)

So far I have tried:

  • ctorrent only lets you specify a single file or directory
  • mktorrent only lets you specify a single file or directory
  • transmission-create only lets you specify a single file or directory
  • py3torrentcreator only lets you specify a single file or directory. It does allow you to specify a pattern of files to exclude, but there are way too many other files to exclude them individually.

I also tried using the Python bindings for libtorrent, but their add_files method strips out the directory names:

>>> import libtorrent as lt
>>> fs = lt.file_storage()
>>> lt.add_files(fs, 'dirA/fileA1')
>>> lt.add_files(fs, 'dirB/fileB1')
>>> print fs.at(0).path
>>> t = lt.create_torrent(fs)
>>> lt.set_piece_hashes(t, '.')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: No such file or directory

Is there any way to accomplish this?

  • Not sure if it can be done directly, but a temporary directory structure with the selected files symlinked to the appropriate places works well for ctorrent. Dec 27, 2014 at 1:11

2 Answers 2


The easiest way to do this, that I know of, is to create a single directory containing symlinks to the different files or directories you would like to add to the torrent.

Add symlinks to a parent directory
cd ~/Shared/parent-dir/
ln -s /path/to/file
ln -s /path/to/dir

Create your torrent
Testing with transmission-create, you can create a new torrent using this source folder and each symlink will be traversed.

transmission-create ~/Shared/parent-dir/

There is no way to store the full filepath in a torrent's meta info for files that are not descendants of parent-dir. When a peer downloads the multi-file torrent, a directory is created using name of the torrent that is found in its meta info. This directory is used as the top most parent directory for all files included in the meta info.

Here is the output of the meta info for a torrent I have called bt-symlinks.torrent. Notice how only paths to files are stored in the meta info and they always begin with the name(infile)1 used as their top most2 directory3.

transmission-show bt-symlinks.torrent

Name: bt-symlinks
File: .torrent


  Name: bt-symlinks
  Hash: 35af9b734284f9259763defe6095424fe3b79b42
  Created by: Transmission/2.82 (14160)
  Created on: Sat Dec 27 12:04:59 2014
  Piece Count: 2357
  Piece Size: 64.00 KiB
  Total Size: 154.4 MB
  Privacy: Public torrent



  bt-symlinks/bt-symlinks.torrent (57.40 kB)
  bt-symlinks/gifs/Bill-Cosby-Jell-o-GIF.gif (810.3 kB)
  bt-symlinks/gifs/Firefly_Lantern_Animation_by_ProdigyBombay.gif (485.2 kB)
  bt-symlinks/gifs/L-cake.gif (455.2 kB)
  bt-symlinks/gifs/L-sweets.gif (871.0 kB)
  bt-symlinks/gifs/Metroid (NES) Music - Kraids Hideout.mp4 (4.16 MB)
  bt-symlinks/gifs/Phantasy Star II_Mother Brain.gif (530.5 kB)
  • It looks like this is the best that can be done with current tools. It would be nice if torrent creators allowed one to separate out the torrent name from the list of paths, but I guess that will go on my infinite TODO list. Thanks for the symlink trick – it works well! Dec 28, 2014 at 3:52
  • Yeah, if such functionality were to be added to a client for downloading, the torrent would no longer be able to keep those files. Maybe the client could allow you to send files/dirs to different paths and then create symlinks so the torrent could still track/share it. Also, search "bittorrent protocol specs" for some more in depth resources if you'd like.
    – iyrin
    Dec 28, 2014 at 4:03

You can do this by passing suitable regex patterns to the --include option with torrenttools.

torrenttools create --include ".*dirA/fileA1" ".*dirB/fileB1" dir

See: https://github.com/fbdtemme/torrenttools

Disclaimer: I am the author of this tool.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.