- file="$_DATA/$ITEM/$(POST select $select |PATH)"
- meta="${file%/*}/.index/meta"
-
- read -r length width height tags comment fn <<-EOF
- $(meta_info "$file")
- EOF
- tags="$(UNSTRING "${tags#tags=}" |tr , '\n')"
-
- if [ ! "$deltags" ]; then
- tags="$(printf '%s\n' "${tags},${newtags}" \
- | tr , '\n' |sort -u |tr '\n' , \
- | STRING)"
- else
- detag="${deltags},"; while [ "$detag" ]; do
- tags="$(printf '%s\n' "$tags" |grep -vxFe "${detag%%,*}")"
- detag="${detag#*,}"
+ file="$(POST select $select)"
+ read_meta "${file%.*}" || continue
+
+ tags="$(printf %s\\n "$META_TAGS" |tr , \\n)"
+
+ if [ "$op" = add ]; then
+ extags="$(printf '%s' "${newtags}" |grep -e "^-" |cut -d: -f1 )"
+ [ "$extags" ] && tags="$(printf %s\\n "$tags" |grep -vwFe "$extags")"
+ if printf %s "${newtags}" |grep -e "^-" |grep -qEe "^-[^:]+$"; then
+ tags="$(printf %s\\n "$tags" |grep -vEe '^-[^:]+$')"
+ fi
+ tags="${tags}${BR}${newtags}"
+
+ elif [ "$op" = del ]; then
+ detag="${newtags}${BR}"; while [ "$detag" ]; do
+ tags="$(printf '%s\n' "$tags" |grep -vxFe "${detag%%${BR}*}")"
+ detag="${detag#*${BR}}"