Last active
June 8, 2017 10:16
-
-
Save mems/5475170 to your computer and use it in GitHub Desktop.
Create OpenDocument file (odt, ods, etc.) from folder (unzipped OpenDocument file)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
The original discussion here: http://stackoverflow.com/questions/4957212/how-does-open-office-compress-its-files/16258048#16258048
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
More info about mimetype file here http://www.jejik.com/articles/2010/03/how_to_correctly_create_odf_documents_using_zip/