summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2021-05-22 06:00:18 -0400
committerBen Sima <ben@bsima.me>2021-05-22 06:00:18 -0400
commitd66bc223ea10b697c481d4558ee90aff1ed685f1 (patch)
treea5ce0a15aaf7e789c8219deecf3ca3400d4f9525
parentaeb52055d8ac3c736a41af8a2cdf75751fadb12a (diff)
add dir arg
-rwxr-xr-xcptorrents11
1 files 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 <dir>" && 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