Summary Files Commits Branches @commit @diff @stats
path: root / Year 2 / Computer Graphics Fundamentals / ExerciseJSExtractor.sh
blob: 57d95d3a208c0862d577071ceeeea4193c4b9a7e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/bin/bash

if [ -z "$1" ]; then
	echo "You need to specify location of exercises!"
	exit
fi

createOKGProblemFile() {
	awk 'BEGIN { injs = 0 } /<\/script>/ { injs = 0 }  { if (injs == 1) { gsub(/^\t\t\t/, ""); print } }  /<script>/ { injs = 1 }' "$1" > $(echo "$1" | awk '{ print substr($0, 88, 2) ".js" }')
}

export -f createOKGProblemFile
find "$1" -type f -wholename "*/Problem*/Problem*.html" -exec bash -c 'createOKGProblemFile "{}"' \;