From aa42f2969717eda2e4c9d99943e9b5ee49249183 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Sat, 19 Oct 2024 11:25:51 +0200 Subject: Add junk and latest-recording scripts --- local/bin/junk | 19 +++++++++++++++++++ local/bin/latest-recording | 7 +++++++ 2 files changed, 26 insertions(+) create mode 100755 local/bin/junk create mode 100755 local/bin/latest-recording (limited to 'local/bin') diff --git a/local/bin/junk b/local/bin/junk new file mode 100755 index 0000000..faf9b32 --- /dev/null +++ b/local/bin/junk @@ -0,0 +1,19 @@ +#!/bin/sh + +set -e + +junk_dir="$HOME/data/junk" +[ ! -d "$junk_dir" ] && mkdir "$junk_dir" + +for arg in "$@" +do + dest="$junk_dir/$arg" + if [ -e "$dest" ] + then + echo "$dest already exists, generating a prefix" + identifier="$(seq 100 | xargs -I N sh -c "echo N; test -e '$dest__N' || exit 255" 2> /dev/null | tail -n1)" + dest="$dest"__"$identifier" + fi + mv "$arg" "$dest" && + echo "$arg moved to $dest" || true +done diff --git a/local/bin/latest-recording b/local/bin/latest-recording new file mode 100755 index 0000000..619fa50 --- /dev/null +++ b/local/bin/latest-recording @@ -0,0 +1,7 @@ +#!/bin/sh + +set -e + +recordings_dir="$HOME/recordings" +latest_recording="$(ls "$recordings_dir" | sort --numeric-sort | tail -n1)" +echo "$latest_recording" -- cgit