Обновите все файлы в архиве с помощью 7zip

1416
Maxim V. Pavlov

Я использую версию командной строки 7zip (7za.exe).

У меня есть следующий файл в папке:

7za.exe 1.txt  test.zip 

test.zipсодержит несколько вхождений 1.txtвнутри его структуры с заархивированными папками.

Мне нужно 7zip, чтобы обновить (перезаписать) все 1.txt в test.zip с файлом 1.txt, который расположен вдоль 7za.exe

Можно ли это сделать? Какая команда? Я пробовал 7za.exe u test.zip 1.txt, но это только обновленный 1.txt, который лежит в корневой папке в архиве, но не во внутренних ».

0

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

2
Marco

You can specify the file by the switch -si and read from stdin. With a script you can update all the files. But it worked for me only when the type of archive is 7z. Example:

$ 7z l test.7z 7-Zip [64] 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18 (...) Date Time Attr Size Compressed Name ------------------- ----- ------------ ------------ ------------------------ 2016-04-20 17:20:08 ....A 2 8 1.txt 2016-04-20 17:20:08 ....A 2 dir1/1.txt 2016-04-20 17:20:08 ....A 2 dir2/1.txt 2016-04-20 17:20:16 D.... 0 0 dir2 2016-04-20 17:20:14 D.... 0 0 dir1 ------------------- ----- ------------ ------------ ------------------------ 6 8 3 files, 2 folders $ 7z u test.7z -sidir1/1.txt < 1.txt $ 7z l test.7z (...) Date Time Attr Size Compressed Name ------------------- ----- ------------ ------------ ------------------------ 2016-04-20 17:20:08 ....A 2 9 1.txt 2016-04-20 17:20:08 ....A 2 dir2/1.txt 2016-04-20 17:22:08 ..... 4 9 dir1/1.txt 2016-04-20 17:20:16 D.... 0 0 dir2 2016-04-20 17:20:14 D.... 0 0 dir1 ------------------- ----- ------------ ------------ ------------------------ 8 18 3 files, 2 folders 

In the documentation of 7-Zip 9.20 and 15.14:

Note: The current version of 7-Zip support reading of archives from stdin only for xz, lzma, tar, gzip and bzip2 archives.

LZMA is the default compression method for the 7z archive type. I tried -mm=lzma for zip archive, but it did not work.

0
LPChip

7zip -u option does update the archive, but it respects the folder structure. In order to update all text files, you need to recreate the folder structure and place the textfiles in appropriate locations and then zip the entire folder with update option.

If you want to update the 1.txt file a lot of times and update all the files easily, you can use mklink to create junctions to this 1.txt file so that you only need to update the file once.

Если я знаю точное местоположение всех 1.txt в структуре zip, могу ли я вызвать какую-то команду для каждой из них, чтобы обновить конкретную команду с помощью `u`? Maxim V. Pavlov 8 лет назад 1

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