commit c192f0a0f44873c9662d8594f88df6b338e5bfda Author: Christoph Lohmann <20h@r-36.net> Date: Thu, 25 May 2023 06:38:19 +0200 Add first mememblob scripts. Diffstat:
A | dir2meme | | | 27 | +++++++++++++++++++++++++++ |
A | dirrename2meme | | | 36 | ++++++++++++++++++++++++++++++++++++ |
2 files changed, 63 insertions(+), 0 deletions(-)
diff --git a/dir2meme b/dir2meme @@ -0,0 +1,27 @@ +#!/bin/bash + +if [ $# -lt 1 ]; +then + printf "usage: %s file.meme\n" "$(basename "$0")" >&2 + exit 1 +fi + +memefile="$1" +outname="${memefile%.*}" +outzip="${outname}.memeblob.zip" + +printf "meme\n" > ${memefile} +find . -type f \ +| while read -r medianame; +do + filename="$(basename "${medianame}")" + memetag="${filename%.*}" + printf "#%s %s\n" "${memetag}" "${filename}" >> ${memefile} + zip -u "${outzip}" "${filename}" +done + +zip -u "${outzip}" "${memefile}" +rm "${memefile}" + +printf "%s\n" "${outzip}" + diff --git a/dirrename2meme b/dirrename2meme @@ -0,0 +1,36 @@ +#!/bin/sh + +if [ $# -lt 1 ]; +then + printf "usage: %s file.meme\n" "$(basename "$0")" >&2 + exit 1 +fi + +outfile="$1" + +printf "meme\n" > ${outfile} +find . -type f \ +| while read -r medianame; +do + basemedianame="$(basename "${medianame}")" + newfilename="$(printf "%s" "${basemedianame}" \ + | tr -c 'a-zA-Z0-9.-_' '_')" + if [ "${basemedianame}" != "${newfilename}" ]; + then + mv "${medianame}" "${newfilename}" + printf "%s -> %s\n" "${basemedianame}" "${newfilename}" + fi + mpv "${newfilename}" + printf "%s\n" "${newfilename}" + memetag="$(thinglaunch -o -p "memetag> ")" + if [ "${memetag}" = "quit" ]; + then + exit 0 + fi + + if [ -n "${memetag}" ]; + then + printf "#%s %s\n" "${memetag}" "${newfilename}" >> ${outfile} + fi +done +