3 . "$_EXEC/cgilite/storage.sh"
4 . "$_EXEC/indexmeta.sh"
7 for tn in $(seq 1 $(POST_COUNT tag)); do
8 newtags="$(POST tag $tn)${BR}${newtags}"
10 newtags="$(POST newtag |tr -d '\r' |tr , '\n')${BR}${newtags}"
12 while [ "${newtags#${BR}}" != "${newtags}" ]; do newtags="${newtags#${BR}}"; done
13 while [ "${newtags%${BR}}" != "${newtags}" ]; do newtags="${newtags%${BR}}"; done
15 [ "$(POST op)" = del ] && deltags="$newtags"
17 echo "x $newtags x" >&2
19 for select in $(seq 1 $(POST_COUNT select)); do
20 file="$_DATA/$ITEM/$(POST select $select |PATH)"
21 meta="${file%/*}/.index/meta"
23 read -r length width height tags comment fn <<-EOF
26 tags="$(UNSTRING "${tags#tags=}" |tr , '\n')"
28 if [ ! "$deltags" ]; then
29 extags="$(printf '%s' "${newtags}" |grep -e "^-" |cut -d: -f1 )"
30 [ "$extags" ] && tags="$(printf %s\\n "$tags" |grep -vwFe "$extags")"
31 if printf %s "${newtags}" |grep -e "^-" |grep -qEe "^-[^:]+$"; then
32 tags="$(printf %s\\n "$tags" |grep -vEe '^-[^:]+$')"
34 tags="$(printf '%s\n' "${tags},${newtags}" \
35 | tr , '\n' |sort -u |tr '\n' , \
38 detag="${deltags}${BR}"; while [ "$detag" ]; do
39 tags="$(printf '%s\n' "$tags" |grep -vxFe "${detag%%${BR}*}")"
40 detag="${detag#*${BR}}"
42 tags="$(printf '%s\n' "$tags" |sort -u |tr '\n' , |STRING)"
44 tags="${tags#,}"; tags="${tags%,}"
47 grep -avF " $fn" "$meta" >"${meta}.tmp"
49 printf '%i %i %i tags=%s comment=%s %s\n' \
50 "$length" "$width" "$height" "$tags" \
51 "${comment#comment=}" "$fn" \
53 mv "${meta}.tmp" "$meta"