Files
make_torrent/make_torrent.sh
2025-04-23 17:55:50 +00:00

36 lines
989 B
Bash

#!/bin/bash
# Prompt user for input
read -rp "Enter source directory (where folders are): " SOURCE_DIR
read -rp "Enter destination directory (where .torrent files go): " DEST_DIR
read -rp "Enter tracker URL: " TRACKER_URL
# Validate source
if [ ! -d "$SOURCE_DIR" ]; then
echo "Source directory does not exist. Exiting."
exit 1
fi
# Create destination directory if it doesn't exist
mkdir -p "$DEST_DIR"
# Loop through each subdirectory in the source
for dir in "$SOURCE_DIR"/*; do
if [ -d "$dir" ]; then
folder_name=$(basename "$dir")
torrent_file="${folder_name}.torrent"
echo "Creating torrent for: $folder_name"
# Generate torrent with 8 MB piece size
mktorrent -a "$TRACKER_URL" -l 23 -o "${SOURCE_DIR}/${torrent_file}" "$dir"
# Move to destination
mv "${SOURCE_DIR}/${torrent_file}" "$DEST_DIR"
echo "Moved $torrent_file to $DEST_DIR"
fi
done
echo "All torrents created and moved successfully."