Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/scripts/linux/autotag_objects.sh
blob: 45e3b672b7d9af109bee936131dc355353c01763 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh -e

cd "`dirname \"$0\"`/../.."

for OBJECT in $(find assets/ -name *.object); do

  EXISTING_TAGS=$(./dist/json_tool --opt '/tags' "$OBJECT")
  if test "x$EXISTING_TAGS" != "x"; then
    echo "Skipping $OBJECT; it already has tags..."
    continue
  fi

  echo "Automatically tagging $OBJECT"

  RACE_TAGS=$(./dist/json_tool --opt '/race' "$OBJECT" --array)
  CATEGORY_TAGS=$(./dist/json_tool --opt '/category' "$OBJECT" --array)
  TYPE_TAGS=$(./dist/json_tool --opt '/objectType' "$OBJECT" --array)

  TAGS=$(./dist/json_tool -j "$RACE_TAGS" -j "$CATEGORY_TAGS" -j "$TYPE_TAGS" --get '/*' --array-unique)
  ./dist/json_tool -i --set '/tags' "$TAGS" --after objectName "$OBJECT"
done