#!/bin/sh
files=$(find /DocumentViewer/Office/src -type f)
for file in $files
do
	ext=$(echo "$file" | awk -F "." '{print tolower($NF)}')
	targetExt=""
	if [ "$ext" = "ppt" ] || [ "$ext" = "odp" ]; then
		targetExt="pptx"
	elif [ "$ext" = "xls" ] || [ "$ext" = "ods" ]; then
		targetExt="xlsx"
	elif [ "$ext" = "doc" ] || [ "$ext" = "odt" ] || [ "$ext" = "rtf" ]; then
		targetExt="docx"
	fi
	if [ -z "$targetExt" ]; then
		continue
	fi
	soffice --headless --convert-to "$targetExt" --outdir /DocumentViewer/Office/dest/ "$file"
done
