From cead8b541a508651ba8471b8011097904b051fb0 Mon Sep 17 00:00:00 2001 From: Pim van Pelt Date: Sun, 20 Oct 2024 15:39:23 +0200 Subject: [PATCH] Allow addpic.sh to specify the directory/date --- addpic.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/addpic.sh b/addpic.sh index da2026d..9d22ab0 100755 --- a/addpic.sh +++ b/addpic.sh @@ -1,26 +1,26 @@ #!/usr/bin/env bash -[ $# -ne 2 ] && { - echo "Usage: addpic.sh " +[ $# -lt 2 -o $# -gt 3 ] && { + echo "Usage: addpic.sh [date] " echo "Example: $0 ~/Pictures/Screenshot\ 2024-08-18\ at\ 23.32.55.png fusion.png" + echo "Example: $0 ~/Pictures/Screenshot\ 2024-08-18\ at\ 23.32.55.png 2024-08-18 fusion.png" exit } infile=$1; shift +date=$(date +%Y-%m-%d) +[ $# -eq 2 ] && { date=$1; shift; } outfile=$(basename $1); shift - [ -r "$infile" ] || { echo "Can't read infile $infile" exit } -today=$(date +%Y-%m-%d) - -cmd="magick \"$infile\" -resize 400x static/img/thumbnails/$today/$outfile" +cmd="magick \"$infile\" -resize 400x static/img/thumbnails/$date/$outfile" echo "Running: $cmd" eval $cmd -cmd="magick \"$infile\" -resize 4000000@\> static/img/fullsize/$today/$outfile" +cmd="magick \"$infile\" -resize 4000000@\> static/img/fullsize/$date/$outfile" echo "Running: $cmd" eval $cmd