Unzip/zip ODT files with 7-zip

2006-06-19
2012-12-08
  • Nobody/Anonymous

    G'day everyone

    Slightly off-topic, but I'm told that an ODT file (OpenDocument Text) is basically a zip file, so you can unzip it, change it, and zip it up again.  However, I fail to make this work with 7-zip.  Does anyone know what settings I should use to unzip and rezip an ODT file so that it still works?

    The procedure is roughly this:

    1. Change ODT file's extension to "zip"
    2. Unzip it using 7-zip
    3. Change the folder name to something else, to avoid overwriting the old file
    4. Zip it up again using 7-zip
    5. Change the file extention to "odt"
    6. Double-click it, and hope that OpenOffice.org recognises it as a valid OpenDocument file

    Thanks for any help
    Samuel
    (SF user leuce, not logged in)

     
    • Nobody/Anonymous

      works with 4.42
      #7z.exe x test.odt
      //Killy

       
      • Nobody/Anonymous

        and context menu too...
        //Killy

         
    • Guillermo Gabrielli

      There are two thing that can cause problems:
      1) The paths
      2) The compression method

      1) The files must be in the same folder than in the original. Example (one of my ODT files):
      content.xml
      meta.xml
      mimetype
      settings.xml
      styles.xml
      Configuration2\accelerator\current.xml
      META-INF\manifest.xml
      Thumbnails\thumbnail.png

      2) OpenOffice.org, Windows XP and most zip programs only support Deflate (not Deflate64) and Store.

      Try the following (Using Windows Explorer):
      A) 1) Select the odt file, right click and choose Extract here
      2) Select the new files, right click and choose "Add to archive..."
      3) Write a name different that the original, with extension odt. Select Archive Format: Zip, Compression Method: Deflate, the compression level and click OK.
      4) Delete the files created in the pass 1
      5) "Double-click it, and hope that OpenOffice.org recognises it as a valid OpenDocument file"

      or B) 1) Select the odt file, right click and choose Extract to [The name of your file]\ You can configure the context menuoptions in 7zFM: Tools -> Options -> Plugins -> Options
      2) Go to the new folder. Select all files, right click and choose "Add to archive..."
      3) As A. Then cut the archive (or write ..\ at the start of the name in the Add to archive dialog, to create the archive in the upper folder)
      4) Go to the upper folder, paste the archive and delete the folder created in the pass 1
      5) "Double-click it, and hope that OpenOffice.org recognises it as a valid OpenDocument file"

       
    • Nobody/Anonymous

      IF you want give a try to this script (command line only): just cut it and paste it into a file like ooorepak.bat and put it in your c:\command directory. I wrote it in a hurry but it should work:

      --%<---Begin ooorepak.bat-----

      echo off
      if dummy%1==dummy goto noarg
      set src=%1
      set dest=%1
      set temp=%~n1
      if dummy%2==dummy goto start

      set dest=%2
      set temp=%~n2

      start

      c:\progra~1\7-zip\7z x -tzip %src% -o%temp%

      rem comment the following line if you want lossless optimization of embedded images

      goto repak

      rem programs "optipng.exe" and "jpegoptim.exe" are required: be warned it can be really slow
      if not exist %temp%\Pictures goto repak

      cd %temp%\Pictures

      for %%a in (*.png) do optipng  -zc1-9 -zm1-9 -zs03 -f0-5 -zw32k -q %%a
      for %%a in (*.jpg) do jpegoptim  %%a

      cd ..\..

      :repak
      cd %temp%

      rem change the settings at will
      c:\progra~1\7-zip\7z a -tzip -mx9 ..\%dest%

      cd ..
      rmdir /s /q temp

      goto end

      :noarg
      echo You must  at least provide the source filename
      echo Usage:
      echo ooorepak <sourcefile> [<destinationfile>]
      echo if [<destinationfile>] is omitted  the original is overwritten

      end:

      --%<---end ooorepak.bat-----

      I hope this forum does not screw up the script (assuming i did type it correctly).
      Obviously no warranty so backup some document and test the script on the copy before production use.

      Ddot

       

Log in to post a comment.