From: Paul Hänsch Date: Sat, 14 Jul 2018 13:06:10 +0000 (+0200) Subject: implemented full multi file tagging X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=f99cce3548251966cd0b7c9ead81460e2f14466c;p=serve0 implemented full multi file tagging --- 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