From d66bc223ea10b697c481d4558ee90aff1ed685f1 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Sat, 22 May 2021 06:00:18 -0400 Subject: add dir arg --- cptorrents | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cptorrents b/cptorrents index 446bc13..27bd8e1 100755 --- a/cptorrents +++ b/cptorrents @@ -1,6 +1,9 @@ #!/usr/bin/env sh -files=$(ls ~/Downloads/*.torrent) +[[ ! $# -eq 1 ]] && echo "usage: cptorrents " && exit 1 + +dir=${1:-~/Downloads} +files=$(find $dir -name "*.torrent") if [ -n "$files" ]; then printf "selected torrents:\n$files\n\n" @@ -8,11 +11,11 @@ if [ -n "$files" ]; then case $reply in n | N | no | NO ) exit 1;; *) printf "syncing\n"; - rsync -av ~/Downloads/*.torrent ben@dev.simatime.com:/mnt/campbell/ben/torrents/in; - rm ~/Downloads/*.torrent; + rsync -av ${files[@]} ben@dev.simatime.com:/mnt/campbell/ben/torrents/in; + rm $dir/*.torrent; exit 0; esac else echo "No torrents found." - exit 1; + exit 1 fi -- cgit v1.2.3