#!/bin/bash
# /usr/local/bin/heard
# https://crystalfaeries.net/posix/bin/heard
# celeste:crystalfaery HEARD 2017-08-21 06:29:06+00:00
# The purpose of this script is to mark as "heard"
# an entire folder of images of the same file .extension
# as that we have been prompted to examine (e.g. via gwenview)
# ONE of the images contained within that folder,
# and then we switched to BROWSE mode and witnessed
# the thumbnails of the images in the folder,
# and we wish to not have to step through
# each image in the folder via our /usr/local/bin/images script.
# Because upon launch gwenview to view an image,
# we have already copied the file path of the image into the clipboard,
# the usage method is to open or switch to a terminal window,
# type the word "heard" followed by a space,
# and then paste the filepath from the clipboard,
# and hit "enter".
# WE SHOULD recode this to accept multiple arguments vs only 1.
if [ $# -ne 1 ]
then
head -n 18 "${0}"
else # accept a file URL syntax prefix, a http: or https: prefix for our own website content, and a /home file path with leading garbage we ignore:
target=$(echo "${1}" | sed 's/^file:\/\///; s/^.*\/home\//\/home\//; s/^http:\/\/crystalfaeries.net\//\/home\//; s/^https:\/\/crystalfaeries.net\//\/home\//')
#echo "TARGET: ${target}" # debug
real="$(realpath "${target}")"
#echo "REAL: ${real}" # debug
rdir="${real%/*}"
#echo "RDIR: ${rdir}" # debug
rname="${real##*/}"
#echo "RNAME: ${rname}" # debug
rext="${rname##*.}"
#echo "REXT: ${rext}" # debug
#echo "SEEN:" # debug
ls -d "${rdir}"/*."${rext}" >> $HOME/documents/.dush.media.txt
fi
syntax highlighted by Code2HTML, v. 0.9.1