Bittorrent is a popular peer-to-peer file sharing protocol that allows users to download large files, such as movies, music, and software, in smaller pieces from multiple sources. Automating the process of downloading torrents using scripts can save time and effort. However, the latest version of Bittorrent has introduced some frustrating issues, particularly with unwanted files and directories. In this article, we will discuss these issues and provide a workaround.
Unwanted Files in Torrents
Sometimes, when downloading torrents, you may encounter unwanted files that are not part of the original content. These files can be annoying and take up valuable disk space. In the latest version of Bittorrent, these unwanted files are not being moved or deleted properly, resulting in external scripts and other unnecessary files being saved.
Identifying Unwanted Files
To identify unwanted files, you can check the "Downloads" directory where Bittorrent saves the downloaded files. Look for files that do not have the expected file extension or have strange names. You can also check the torrent file metadata to see if it includes any unwanted files.
Workaround for Unwanted Files
To prevent unwanted files from being downloaded, you can modify the Bittorrent script to filter out unwanted files based on their file extension or name. Here's an example of how to do it using a simple shell script:
#!/bin/bash
# Bittorrent download script with file filtering
torrent_file="path/to/torrent_file.torrent"
download_dir="path/to/download_directory"
# Extract torrent metadata
torrent=$(transmission-show $torrent_file --format json)
info=$(echo $torrent | jq '.info.files[]' | jq '.name, .length, .path')
# Filter out unwanted files
unwanted_files=('file1.exts' 'file2.exts' 'file3.exts')
filtered_files=($(echo $info | jq -r '.[] | select(.name != (any(select(. as $unwanted | select(.name == $_.name)) | not)) | .path'))))
# Download torrent
transmission-create --add $torrent_file --download-dir $download_dir --files ${filtered_files[@]}
In this example, we use the Transmission BitTorrent client and the jq tool for JSON processing. The script extracts the torrent metadata, filters out unwanted files based on their file extension, and downloads the remaining files to the specified directory.
Deleting Unwanted Directories
If unwanted directories are being created during the download process, you can modify the script to delete them after the download is complete. Here's an example:
#!/bin/bash
# Bittorrent download script with file filtering and directory deletion
torrent_file="path/to/torrent_file.torrent"
download_dir="path/to/download_directory"
# Extract torrent metadata
torrent=$(transmission-show $torrent_file --format json)
info=$(echo $torrent | jq '.info.files[]' | jq '.name, .length, .path')
# Filter out unwanted files
unwanted_files=('file1.exts' 'file2.exts' 'file3.exts')
filtered_files=($(echo $info | jq -r '.[] | select(.name != (any(select(. as $unwanted | select(.name == $_.name)) | not)) | .path'))))
# Download torrent
transmission-create --add $torrent_file --download-dir $download_dir --files ${filtered_files[@]}
# Delete unwanted directories
find $download_dir -type d -name "unwanted_directory_name" -exec rm -r {} \;
In this example, we use the find command to search for directories with the specified name in the download directory and delete them recursively.
- The latest version of Bittorrent may not move or delete unwanted files properly during the download process.
- To prevent unwanted files from being downloaded, you can modify the Bittorrent script to filter out unwanted files based on their file extension or name.
- To delete unwanted directories after the download is complete, you can modify the script to use the find command.
References: