Как заархивировать папку в формат odt

1061
Denis

Я извлекаю файл .odt (открытый офис) и делаю с ним некоторые манипуляции. А потом, когда я хочу вернуть файл обратно, у меня возникает проблема.

например, если я вхожу в каталог с распакованным файлом odt, и я делаю что-то вроде этого:

cd /dir/with/uziped/odt zip -r ../test.odt . 

Все работает отлично. Я получил действительный файл открытого офиса, и я могу работать с ним.

Но затем я пробую zip из не корневой папки odt У меня поврежден файл odt, после этой команды:

zip -r test.odt /dir/with/uziped/odt 

Так что это не сработает.

«/ dir / with / uziped / odt» включает пару папок и XML-файлы

ОБНОВЛЕНИЕ :
Основная проблема в том, что если я попытаюсь использовать архиватор, а не из корневого каталога, он берет все каталоги в пути с помощью команды:

7z a -tzip tt.odt temp/* 

Выход будет:

Compressing temp/Configurations2/accelerator/current.xml  Compressing temp/META-INF/manifest.xml  Compressing temp/Thumbnails/thumbnail.png  Compressing temp/content.xml  Compressing temp/manifest.rdf  Compressing temp/meta.xml  Compressing temp/mimetype  Compressing temp/settings.xml  Compressing temp/styles.xml 

но мне не нужно сжимать временную директорию. Мне нужно только добавить все файлы из этого каталога в новый архив, например так:

Compressing Configurations2/accelerator/current.xml  Compressing META-INF/manifest.xml  Compressing Thumbnails/thumbnail.png  Compressing content.xml  Compressing manifest.rdf  Compressing meta.xml  Compressing mimetype  Compressing settings.xml  Compressing styles.xml  
0

1 ответ на вопрос

0
karel

Streaming input and output of zip

zip will also accept a single dash - as the zip file name, in which case it will write the zip file to standard output, allowing the output to be piped to another program.

For example the dd program can write the standard output to a file in another location. In the following example dd writes the standard output to a new file called test.zip (a zip archive) located on the user Denis's desktop.

cd /dir/with/uzipped/odt zip -r - . | dd of=/home/Denis/Desktop/test.zip 

The of that is typed after dd stands for output file. The . that comes after the single dash denotes the current directory.

Converting a zip file to odt

Because an .odt file is structured like a .zip file, you can view the contents of an .odt file by renaming the file's extension to .zip and then extracting the files from the zip archive. If you have preserved the directory structure of the original .odt file, you can convert the .zip file back to an .odt file after you have made changes to it by renaming the file's .zip extension back to .odt.

все команды уже под вопросом, os это linux Denis 8 лет назад 0
Мне нужно это для сценария Python Denis 8 лет назад 0

Похожие вопросы