Skip to main content

Add a script for sorting out book cover images

ID
09fd08a
date
2023-12-11 08:20:50+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
0804d56
message
Add a script for sorting out book cover images
changed files
2 files, 35 additions

Changed files

images/README.md (5798) → images/README.md (6107)

diff --git a/images/README.md b/images/README.md
index 006ef63..017310c 100644
--- a/images/README.md
+++ b/images/README.md
@@ -103,6 +103,17 @@ These scripts are for working with images and other visual material.
       </table>
     </p>
   </dd>
+  
+
+  <dt>
+    <a href="https://github.com/alexwlchan/scripts/blob/main/images/move_cover_image">
+      <code>move_cover_image</code>
+    </a>
+  </dt>
+  <dd>
+    copy an image from my Desktop folder into my book tracker.
+    This is very specific to my setup and unlikely to be useful to anyone else.
+  </dd>
 
   <dt>
     <a href="https://github.com/alexwlchan/scripts/blob/main/images/pdfthumb">

images/move_cover_image (0) → images/move_cover_image (685)

diff --git a/images/move_cover_image b/images/move_cover_image
new file mode 100755
index 0000000..ba63c64
--- /dev/null
+++ b/images/move_cover_image
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+# Copy an image from my Desktop folder into my book tracker.
+#
+# This is very specific to my setup and unlikely to be useful to anyone else.
+
+set -o errexit
+set -o nounset
+
+LATEST_DOWNLOAD=$(latest_download)
+LATEST_REVIEW=$(git ls-files -o --exclude-standard)
+echo "$LATEST_DOWNLOAD"
+echo "$LATEST_REVIEW"
+
+filename=$(basename -- "$LATEST_REVIEW" .md)
+year=$(basename -- $(dirname -- "$LATEST_REVIEW"))
+
+image_filename=$(basename -- "$LATEST_DOWNLOAD")
+image_extension="${image_filename##*.}"
+
+image_path=~/repos/books.alexwlchan.net/src/covers/$year/$filename.$image_extension
+
+echo "$image_path"
+mv "$LATEST_DOWNLOAD" "$image_path"
+dominant_colours "$image_path"