#!/bin/bash
# Quick script to load a whole directory into transmission-daemon
# using transmission-remote and environment authentication
# Could also use '--netrc' with corresponding external configuration

# Usage: load-to-transmission-daemon.sh torrent/path/
# **Requires trailing '/' to search whole directory for '*.torrent'

if [ -z "$TR_AUTH" ]; then
	echo "Must set TR_AUTH in local environment to access transmission-daemon"
	exit 1
fi

for filename in "$1"*.torrent; do
    transmission-remote --authenv --add "$filename"
    rm "$filename"
done

#!/bin/bash
# Quick script to load a whole directory into transmission-daemon
# using transmission-remote and environment authentication
# Could also use '--netrc' with corresponding external configuration

# Usage: load-to-transmission-daemon.sh torrent/path/
# **Requires trailing '/' to search whole directory for '*.torrent'

if [ -z "$TR_AUTH" ]; then
	echo "Must set TR_AUTH in local environment to access transmission-daemon"
	exit 1
fi

for filename in "$1"*.torrent; do
    transmission-remote --authenv --add "$filename"
    if [ $? -eq 0 ]; then
		echo "Removing $filename"
		rm "$filename"
	else
		echo "Retaining $filename"
	fi

done

Add result check to attempt to load torrent file for conditional `rm`
Add result check to attempt to load torrent file for conditional `rm`

Now only successfully added *.torrent files will be removed, with acknowledgement, while failed additions will be left alone for the user to check.
