Skip to content
odt-strip-frames.sh 540 B
Newer Older
Colomban Wendling's avatar
Colomban Wendling committed
#!/bin/sh

set -e

INPUT="$1"
OUTPUT="$2"

# check input arguments
if [ "$#" != 2 -o -z "$INPUT" -o -z "$OUTPUT" ]; then
  echo "USAGE: $0 INPUT OUTPUT" >&2
  exit 1
fi

# input must be a file
[ -f "$INPUT" ]

tempdir=$(mktemp -d)
unzip -q "$INPUT" -d "$tempdir"
# fixup the file
Colomban Wendling's avatar
Colomban Wendling committed
xsltproc -o "$tempdir/content.xml.tmp" "$(dirname "$0")/strip-frames.xsl" "$tempdir/content.xml"
mv -f "$tempdir/content.xml.tmp" "$tempdir/content.xml"

# build the output
(
  cd "$tempdir"
  zip -q -r - mimetype .
Colomban Wendling's avatar
Colomban Wendling committed
) > "$OUTPUT"

# cleanup
rm "$tempdir" -rf