Skip to content

Instantly share code, notes, and snippets.

@nmandery
Created April 7, 2011 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nmandery/907878 to your computer and use it in GitHub Desktop.
Save nmandery/907878 to your computer and use it in GitHub Desktop.
unpack odf files
#!/bin/sh
set -e
TSTAMP=$(date +%Y%m%d-%H%M%S)
ODFFILE=$1
ODFDIR="$ODFFILE-unpacked"
[ -f "$ODFFILE" ] || exit 1
[ -d "$ODFDIR" ] && mv "$ODFDIR" "$ODFDIR.$TSTAMP"
mkdir $ODFDIR
unzip "$ODFFILE" -d "$ODFDIR"
# format the xml
for XMLFILE in $(find "$ODFDIR" -type 'f' -name '*.xml'); do
TMPFILE="$XMLFILE.formated"
xmllint --format --nowarning --recover "$XMLFILE" >"$TMPFILE"
mv "$TMPFILE" "$XMLFILE"
done
echo "Created $ODFDIR"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment