Skip to main content

add the file by year base script

ID
6a9ad06
date
2022-09-26 17:51:35+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
b2ccd76
message
add the file by year base script
changed files
1 file, 19 additions

Changed files

_file_by_year (0) → _file_by_year (349)

diff --git a/_file_by_year b/_file_by_year
new file mode 100755
index 0000000..e9e40e0
--- /dev/null
+++ b/_file_by_year
@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+# This is a shortcut for 'mv' that I use for filing documents.
+#
+# It files documents into per-year subdirectories of a given directory.
+#
+# See e.g. 'fun', 'screenshot', 'wellcome'
+
+set -o errexit
+set -o nounset
+
+DIRNAME="$1"
+YEAR="$(date +"%Y")"
+
+mkdir -p "$DIRNAME/$YEAR"
+
+for f in "${@:2}"
+do
+  mv "$f" "$DIRNAME/$YEAR"
+done