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 for select in $(seq 1 $(POST_COUNT select)); do
18 file="$_DATA/$ITEM/$(POST select $select |PATH)"
19 meta="${file%/*}/.index/meta"
21 read -r length width height tags comment fn <<-EOF
24 tags="$(UNSTRING "${tags#tags=}" |tr , '\n')"
26 if [ ! "$deltags" ]; then
27 extags="$(printf '%s' "${newtags}" |grep -e "^-" |cut -d: -f1 )"
28 [ "$extags" ] && tags="$(printf %s\\n "$tags" |grep -vwFe "$extags")"
29 if printf %s "${newtags}" |grep -e "^-" |grep -qEe "^-[^:]+$"; then
30 tags="$(printf %s\\n "$tags" |grep -vEe '^-[^:]+$')"
32 tags="$(printf '%s\n' "${tags},${newtags}" \
33 | tr , '\n' |sort -u |tr '\n' , \
36 detag="${deltags}${BR}"; while [ "$detag" ]; do
37 tags="$(printf '%s\n' "$tags" |grep -vxFe "${detag%%${BR}*}")"
38 detag="${detag#*${BR}}"
40 tags="$(printf '%s\n' "$tags" |sort -u |tr '\n' , |STRING)"
42 tags="${tags#,}"; tags="${tags%,}"
45 grep -avF " $fn" "$meta" >"${meta}.tmp"
47 printf '%i %i %i tags=%s comment=%s %s\n' \
48 "$length" "$width" "$height" "$tags" \
49 "${comment#comment=}" "$fn" \
51 mv "${meta}.tmp" "$meta"