Moosh - Exporting Categories

sudo -u www-data moosh category-list |\
tail -n +2 | sed 's/ \{3,\}/\"\,\"/g' |\
sed 's/^/\"/g' |\
sed 's/$/\"/g' |\
sed 's/\,\"\"$//g' |\
awk -F '\"\,\"' '{ print $1 "%" $NF "/" $2 }' |\
sed s/\"//g |\
awk -F "/" 'NF==3' |\
awk -F "/" '{ print $1 "/" $2 "/" $3 }' |\
sed 's/\/$//g' |\
awk -F "/" 'NF==3' |\
sort -u -t% -k2,2 |\
awk -F "%" '{ print $2 "%" $1}' |\
grep -v 'Top/Archive\|Training & Development - Cork\|Top/Miscellaneous\|Part-Time\|Full-Time' |\
sed 's/Business Faculty/Business/g' |\
sed 's/Computing Science Faculty/Computing/g' |\
sed 's/Engineering Faculty/Engineering/g' |\
sed 's/Graduate Business School/GBS/g' |\
sed 's/Griffith Language Institute/GLI/g' |\
sed 's/Law Faculty/Law/g' |\
sed 's/Media Faculty/Media/g' |\
sed 's/English for Academic Purposes/English/g' > /home/x/test

Resulting file format: Top/Professional Accountancy/Cork Campus%1761

Loop on the file above and create the Staff Info pages on all faculties ie Computing > Dublin > Computing-Staff Info-Campus

while read p; do \
echo $p |\
sed 's/\//%/g' |\
sed 's/ Campus//g' |\
sed 's/ campus//g' |\
awk -F "%" '{ print "sudo -u www-data moosh course-create --category " $NF " --fullname=\"" $2 "-Staff Info-" $3 "\" " "\"" $2 "-Staff Info-" $3 "\" " }'; \
done < /home/x/test

Loop on the file above and create the Student Info pages on all faculties ie Computing > Dublin > Computing-Student Info-Campus

while read p; do \
echo $p |\
sed 's/\//%/g' |\
sed 's/ Campus//g' |\
sed 's/ campus//g' |\
awk -F "%" '{ print "sudo -u www-data moosh course-create --category " $NF " --fullname=\"" $2 "-Student Info-" $3 "\" " "\"" $2 "-Student Info-" $3 "\" " }'; \
done < /home/x/test