From f99cce3548251966cd0b7c9ead81460e2f14466c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Sat, 14 Jul 2018 15:06:10 +0200 Subject: [PATCH] implemented full multi file tagging --- multitag.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 multitag.sh diff --git a/multitag.sh b/multitag.sh new file mode 100644 index 0000000..43484e6 --- /dev/null +++ b/multitag.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +for select in $(seq 1 $(POST_COUNT select)); do + file="$_DATA/$ITEM/$(POST select $select)" + meta="${file%/*}/.index/meta" + fn="${file##*/}" + + while ! mkdir "${meta}.lock"; do + sleep 1 + ps -o pid \ + | grep -q "$(cat "${meta}.lock/pid")" \ + || break + done + printf '%i\n' >"${meta}.lock/pid" + + grep -vF " $fn" "$meta" >"${meta}.lock/mtmp" + read length width height tags comment x <<-EOF + $(grep -F " $fn" "$meta") + EOF + tags="$(printf '%s' "${tags#tags=}" | tr , '\n')" + + for tn in $(seq 1 $(POST_COUNT tag)); do + tags="$tags${BR}$(POST tag $tn |sed -r 's;\t;\\t;g; s;\r;;g;')" + done + tags="$tags${BR}$(POST newtag |sed -r 's;\t;\\t;g;')" + + printf '%s\t%s\t%s\ttags=%s\t%s\t%s\n' \ + "$length" "$width" "$height" \ + "$(printf %s "$tags" |sort -u |tr '\n' ,)" \ + "$comment" "$fn" \ + >>"${meta}.lock/mtmp" + mv "${meta}.lock/mtmp" "$meta" + + rm "${meta}.lock/pid"; rmdir "${meta}.lock" +done -- 2.39.2