mkxp/extra/dump.sh

87 lines
1.5 KiB
Bash
Raw Normal View History

2020-05-06 07:33:51 +00:00
#!/bin/bash
ARRAY=()
ARRAYFILES=()
FILE=$1
mkdir -p preload/Data
rm -f preload/$FILE.json
touch preload/$FILE.json
ruby dump.rb $FILE
while IFS= read -r line; do
if [[ $line == *"::"* ]]; then
continue
fi
if [[ $line == *"!"* ]]; then
continue
fi
if [[ $line == *"true" ]]; then
continue
fi
if [[ $line == *"false" ]]; then
continue
fi
if [[ $line == *"[]" ]]; then
continue
fi
if [[ $line == *":"* ]]; then
value=${line#*:}
2020-05-06 08:02:02 +00:00
fi
if [[ $line == *"-"* ]]; then
value=${line#*-}
fi
value=${value//\*}
value=${value//[[:blank:]]/}
value=${value//\'}
2020-05-06 07:33:51 +00:00
2020-05-06 08:02:02 +00:00
re="^[0-9.-]+$"
if [[ $value =~ $re ]] ; then
continue
fi
re='^EV[0-9]+$'
if [[ $value =~ $re ]] ; then
continue
fi
2020-05-06 07:33:51 +00:00
2020-05-06 08:02:02 +00:00
if [[ $value == 'A' ]] ; then
continue
fi
2020-05-06 07:33:51 +00:00
2020-05-06 08:02:02 +00:00
if [ -z "$value" ] ; then
continue
fi
2020-05-06 07:33:51 +00:00
2020-05-06 08:02:02 +00:00
if [[ " ${ARRAY[@]} " =~ " ${value} " ]]; then
continue
fi
2020-05-06 07:33:51 +00:00
2020-05-06 08:02:02 +00:00
echo $value
ARRAY+=($value)
2020-05-06 07:33:51 +00:00
2020-05-06 08:02:02 +00:00
files="$(find -name "$value.*")"
files="${files//\.\/}"
if [ -z "$files" ] ; then
continue
2020-05-06 07:33:51 +00:00
fi
2020-05-06 08:02:02 +00:00
echo "$files"
ARRAYFILES+=($files)
2020-05-06 07:33:51 +00:00
done < dump.yml
rm dump.yml
echo '[' >> preload/$FILE.json
printf '"%s",\n' "${ARRAYFILES[@]}" | sed '$s/,$//' >> preload/$FILE.json
echo ']' >> preload/$FILE.json
echo "============================================================"
cat preload/$FILE.json
echo "============================================================"