This is a quick python script for creating torrents for each file in directories and sub directories.
We are using the following tools:
- Python Module Torf
- Python module OS
import os from torf import Torrent #Enter your directory rootdir = './test' for subdir, dirs, files in os.walk(rootdir): for file in files: t = Torrent(path=os.path.join(subdir, file), trackers=['https://tracker1.example.org:1234/announce', 'https://tracker2.example.org:5678/announce'], comment='This is a comment') t.private = True t.generate() t.write(os.path.join(subdir, file[:-4]) +'.torrent')
This quick script basically will import both modules if you do not have them you can install them with pip, the root dir variable is your desired folder location.
Using Os module we will interact for each file in the path specified in rootdit variable.
tracker URL will be your private or public tracker link for announcement.
t.private can be changed to False of True depending on your needs.
t.write will remove the last 4 characters of the string in order to hide the extension and not have any type of wrong format and avoid the file.mp4.torrent and will be file.torrent.