nsbin/torrent_handler/find_succeeded.sh
Nico Schottelius df2daf524d init
Signed-off-by: Nico Schottelius <nico@manager.schottelius.org>
2017-07-19 17:15:41 +02:00

27 lines
731 B
Bash
Executable file

#!/bin/sh
# Nico Schottelius
# find succussfully downloaded torrents
TOPABS=$(cd $(dirname $0); pwd -P)
TORDIR="$TOPABS/torrents"
LOGDIR="$TOPABS/logs"
OUTDIR="$TOPABS/out"
SAVEDIR="$TOPABS/fertig"
SAVETOR="$SAVEDIR/torrents"
SEARCHTERM='time left: Download Succeeded!'
TESTLINES="20"
# place downloads into current diretory/out
cd "$LOGDIR"
#for torrent in ${TORDIR}/*; do
for log in *; do
tail -n${TESTLINES} "$log" | grep -q "$SEARCHTERM" >/dev/null
if [ "$?" -eq 0 ]; then
echo "$log" finished.
file=$(tail -n${TESTLINES} "$log" | awk -F: '/^download to:/ { print $2 }' | tail -n1 | sed 's;^ */;/;')
mv "${file}" "${SAVEDIR}"
mv "${TORDIR}/${log}" "${SAVETOR}"
rm "$log"
fi
done