Create ODT files using ZIP
Posted on October 14, 2023 (Last modified on July 2, 2024) • 1 min read • 128 wordsSo I wanted to test something, for which I needed to create or modify an ODT file. Since ODT files are just ZIPs, I thought “open, edit, zip, done” would be sufficient.
It’s not:
The 2nd thing you have to take care of yourself, for the first I wrote a small
Mac automator script, using bin/bash
as shell:
SAVE_DIR="$PWD"
while read input_dir ; do
[[ -d "$input_dir" ]] || continue
cd "$input_dir"
touch _odt_create_log.txt
exec > _odt_create_log.txt
exec 2>&1
set -x
ODT_FILE="../$(basename "$input_dir").odt"
rm -f "$ODT_FILE"
zip "$ODT_FILE" -0 mimetype
zip -ruo "$ODT_FILE" . -x mimetype _odt_create_log.txt
cd "$SAVE_DIR"
set +x
done