picquiz/Scripts/puzzle_seed_from_img.sh
2022-11-07 13:34:26 +01:00

25 lines
434 B
Bash
Executable File

#!/bin/bash
DIR=$1
[ -z "$DIR" ] && DIR="."
for i in "$DIR"/*; do
ANS=${i/${DIR}/}
ANS=${ANS//\//}
ANS=${ANS%.*}
ANS=$(echo "$ANS" | tr [:upper:] [:lower:])
ANS=${ANS//_/ }
ANS=${ANS//:/}
IMG=${i/${DIR}/}
IMG="/images/puzzles/${IMG}"
IMG=${IMG//\/\//\/}
printf "
Puzzle::create([
'picture' => \"${IMG}\",
'answer' => \"${ANS}\",
'user_added' => 1,
'numberOfGames' => 0,
'numberOfHits' => 0,
]);\n"
done