4 . "$_EXEC/cgilite/session.sh" nocookie
8 for tn in $(seq 1 $(POST_COUNT tag)); do
9 newtags="$(POST tag $tn)${BR}${newtags}"
11 newtags="$(POST newtagn |tr -d '\r' |tr , '\n')${BR}${newtags}"
13 if [ "$(POST makegroup)" = true ]; then
17 while [ "${newtags#${BR}}" != "${newtags}" ]; do newtags="${newtags#${BR}}"; done
18 while [ "${newtags%${BR}}" != "${newtags}" ]; do newtags="${newtags%${BR}}"; done
20 [ "$(POST op)" = del ] && deltags="$newtags"
22 for select in $(seq 1 $(POST_COUNT select)); do
23 file="$(POST select $select)"
25 read_meta "${file%.*}" || continue
26 tags="$(printf %s\\n "$META_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' ,)"
37 detag="${deltags}${BR}"; while [ "$detag" ]; do
38 tags="$(printf '%s\n' "$tags" |grep -vxFe "${detag%%${BR}*}")"
39 detag="${detag#*${BR}}"
41 tags="$(printf '%s\n' "$tags" |sort -u |tr '\n' ,)"
43 tags="${tags#,}"; tags="${tags%,}"
46 update_meta "$META_NAME" tags="${tags}" group="${group}"
48 update_meta "$META_NAME" tags="${tags}"
52 ( if [ $(POST_COUNT select) -gt 0 ]; then
54 mv -- "$c_tags.$$" "$c_tags"