This commit is contained in:
Luca Jäntsch
2019-05-29 17:06:29 +02:00
parent c4c36b2787
commit fa6f0f88e0
8 changed files with 125 additions and 18 deletions

38
bash_scripts/generate.sh Executable file
View File

@@ -0,0 +1,38 @@
#!/bin/bash
# relative or absolute path where the classes are
path=../public/data/class/*
# image filetype needs to be the same
file_type=*.jpg
# REGEX
reg='(.*)class\/([0\-9A\-z_]*)\/([0\-9A\-z_]*)\.jpg'
#reg='class\/([0\-9A\-z_]*)'
for i in $path
do
if [ -d "$i" ]; then
#echo "$i"
json_file=$i/user.json
printf '{\n"user":[\n'>$json_file
for j in $i/*
do
if [[ $j == ${file_type} ]]; then
if [[ $j =~ ${reg} ]]; then
echo "${BASH_REMATCH[3]}"
printf '"'>>$json_file
printf ${BASH_REMATCH[3]}>>$json_file
printf '",\n'>>$json_file
else
echo "TEST2"
echo $j
fi
fi
done
cat $json_file | rev | cut -c 3- | rev
fi
done

View File