I think there are only two ways to do it:
--list before and after, and see what's new. Doable in a script, but sounds painful. And of course prone to races.
-t TORRENT -i and look at the
Id: field. At first glance this looks circular, but it turns out TORRENT doesn't have to be an Id. It can be a hash.
So, with method 2:
hash="$( transmission-show FILE.TORRENT | perl -n -E 'say $1 if /^\s*Hash: (.+)$/' )"
id="$(transmission-remote -t "$hash" -i | perl -n -E 'say $1 if /^\s*Id: ([0-9]+)$/' )"
You can combine those all in one line, of course. And you'll have to add your server/authentication options to that
tramission-remote line. (Personally, I have a
t-r script which does that and also adds even-odd row highlighting to
-l output). It looks like this:
if ! [ -r ~/.transmission-netrc ]; then
echo Expected to find a ~/.transmission-netrc file with the username
echo and password.
if [ "xterm" == "$TERM" ]; then
transmission-remote «HOSTNAME» -N ~/.transmission-netrc "$@" | (
if [ "-l" == "$1" ]; then
sed -e "1~2 s|^|`tput setab 149``tput el`|" -e "2~2 s|^|`tput setab 221``tput el`|"
tput setab 7
Note the «HOSTNAME» you'd need to fill in.