[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: [office] How to number a heading?
On 23-05-17 22:28, Regina Henschel wrote: > > Here too the "mimetype" is not the first file in the package. So if > someone can repair the order, that would be nice. LibreOffice does not > look at the order on opening files, but other applications might be less > tolerant. I have attached bash scripts to pack and unpack odf files. This script puts 'mimetype' first and does not compress it. The scripts are developed for linux and require that 'zip' is installed. Save the files in your path and make them executable: chmod a+x pack unpack Now you can use them like this: unpack test.odt pack test_odt Cheers, Jos
#!/usr/bin/env bash set -o errexit set -o nounset set -o pipefail DIR=${1%/} OUTPUT=${2:-} if [ ! -d "$DIR" ]; then echo "Provide a directory to pack." exit 1 fi if [ -z "$OUTPUT" ]; then BASE=${DIR%_*} EXT=${DIR##*_} if [ "${BASE}_$EXT" != "$DIR" ]; then echo "Provide output name or use directory like 'name_ext'." exit 1 fi OUTPUT="$BASE.$EXT" fi if [ "${OUTPUT:0:1}" != "/" ]; then OUTPUT="$PWD/$OUTPUT" fi if [ ! -f "$DIR/mimetype" ]; then echo "No mimetype file present." exit 1 fi if [ ! -f "$DIR/content.xml" ]; then echo "No content.xml file present." exit 1 fi if [ ! -f "$DIR/styles.xml" ]; then echo "No styles.xml file present." exit 1 fi if [ -f "$OUTPUT" ]; then echo deleting "$OUTPUT" rm "$OUTPUT" fi cd "$DIR" || (echo "Failed to enter $DIR."; exit 1) zip -D -X -0 "$OUTPUT" mimetype zip -D -X -9 -r "$OUTPUT" . -x mimetype \*/.\* .\* \*.png \*.jpg \*.jpeg zip -D -X -0 -r "$OUTPUT" . -i \*.png \*.jpg \*.jpeg || test 1 echo Created "$OUTPUT"
#!/usr/bin/env bash # construct an output name DIR=$1 DIR=${DIR/%.odp/_odp} DIR=${DIR/%.odt/_odt} DIR=${DIR/%.ods/_ods} DIR=${DIR/%.odg/_odg} DIR=${DIR/%.otp/_otp} DIR=${DIR/%.ott/_ott} DIR=${DIR/%.ots/_ots} DIR=${DIR/%.otg/_otg} if [ ! -f "$1" ]; then echo "The file '$1' does not exist." exit 1 fi if [ "$1" == "$DIR" ]; then echo "The file '$1' cannot be unpacked." exit 1 fi if [ -e "$DIR" ]; then echo "Directory $DIR already exists." exit 1 fi unzip "$1" -d "$DIR" xmlstarlet fo "$DIR/content.xml" > "$DIR/c" mv "$DIR/c" "$DIR/content.xml" xmlstarlet fo "$DIR/styles.xml" > "$DIR/c" mv "$DIR/c" "$DIR/styles.xml" if [ -e "$DIR/meta.xml" ]; then xmlstarlet fo "$DIR/meta.xml" > "$DIR/c" mv "$DIR/c" "$DIR/meta.xml" fi
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]