This assumes you already have libreoffice installed.
This can be done from the command line without opening the GUI.
Convert .odt to .docx
Convert to .rtf
Convert to text
Bash batch file conversion
A better odt to txt script.
This can be done from the command line without opening the GUI.
Convert .odt to .docx
Code:
libreoffice --headless --convert-to docx yourfile.odt
Convert to .rtf
Code:
libreoffice --headless --convert-to rtf yourfile.odt
Convert to text
Code:
libreoffice --headless --convert-to txt:Text yourfile.odt
Bash batch file conversion
Code:
#!/bin/bash
for file in *.odt; do
libreoffice --headless --convert-to docx "$file"
done
A better odt to txt script.
Code:
#!/bin/bash
# Directory containing .odt files (default: current directory)
INPUT_DIR="."
OUTPUT_DIR="./converted_txt"
# Create output directory if it doesn't exist
mkdir -p "$OUTPUT_DIR"
# Loop through all .odt files in the input directory
for file in "$INPUT_DIR"/*.odt; do
if [[ -f "$file" ]]; then
echo "Converting: $file"
libreoffice --headless --convert-to txt:Text "$file" --outdir "$OUTPUT_DIR"
fi
done
echo "Conversion complete. TXT files saved in: $OUTPUT_DIR"

