Skip to content

Instantly share code, notes, and snippets.

@mems
Last active June 8, 2017 10:16
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 mems/5475170 to your computer and use it in GitHub Desktop.
Save mems/5475170 to your computer and use it in GitHub Desktop.
Create OpenDocument file (odt, ods, etc.) from folder (unzipped OpenDocument file)
#!/bin/sh
# Convert folder (unzipped OpenDocument file) to OpenDocument file (odt, ods, etc.)
usage="usage: $(basename "$0") folder file program to create OpenDocument file (odt, ods, etc.) from folder (unzipped OpenDocument file)"
if [ $# -ne 2 ]; then
echo "$usage"
exit 0
else
if [ ! -d "$1" ]; then
echo "folder not found or not readable"
echo "$usage"
exit 0
fi
fi
cmdfolder=$(cd `dirname "$0"`; pwd -P)
folder=$(cd `dirname "$2"`; pwd -P)
file=$(basename "$2")
absfile="$folder/$file"
cd "$1"
# uncompressed mimetype, see section 17.4 MIME Type Stream of OpenDocument v1.0 specification
zip -0 -X "$file" "mimetype"
list=$(cat <<'END_HEREDOC'
meta.xml
settings.xml
content.xml
Pictures/
Thumbnails/
Configurations2/
styles.xml
manifest.rdf
META-INF/manifest.xml
END_HEREDOC
)
for f in $list
do
zip "$absfile" "$f"
done
cd "$cmdfolder"
@mems
Copy link
Author

mems commented Apr 27, 2013

@mems
Copy link
Author

mems commented Mar 26, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment