Already posted this but on the wrong subforum (Mac requests).
I've managed to write a simple script in 5 minutes (a bit dirty but it works) for adding the multiple folder watch functionality to transmission-daemon (on linux).
It's using inotify-tools.
Code: Select all
#!/bin/bash
inotifywait -q -r -m $1 --format %w%f -e create |
while read file; do
if echo "$file" | grep -iq "\.torrent" ; then
canonfile=$(readlink -f "$file")
dir=$(dirname "$canonfile")
if echo `basename "$file"` | grep -iq "^\._"; then
echo
else
#echo "Waiting for the file to close"
while : ; do
a=`stat -c%s "$canonfile"`
sleep 0.5s
if [ $a -gt 0 ]; then break; fi
done
while : ; do
a=`stat -c%s "$canonfile"`
sleep 5s
if [ $a -eq `stat -c%s "$canonfile"` ]; then break; fi
done
transmission-remote -a "$canonfile" -w "$dir"
rm -f "$canonfile"
fi
fi
done
No, using close_write event will not do it, for example samba will close and reopen the file multiple times during a transfer..
Note: This part " grep -iq "^\._";" is for filtering out the crap Mac OS X will write on a samba share along with the file you copy.
So basically you'll lunch this script from ex. /etc/rc.local with the parameter of the root folder you want to watch. It will recursively watch all the subfolders from then on for .torrents file. This script can be modified to watch only a specific folder (and ran multiple times with different folders to selectively watch a number of folders) by just modifying the first line "inotifywait -q -r -m $1 --format %w%f -e create |" by removing the "-r" parameter.
Cheers!