仅使用7z压缩文件,而不保留路径 [英] Compressing only files using 7z without preserving the path
问题描述
我使用7z命令行可执行文件zip文件,但我看到,虽然添加到归档文件的路径保存在档案中。
如果我这样做
7z a -tzip myzip.zip dir1\dir2\ *
归档myzip.zip将包含路径dir1 \dir2。我不想要这,而是我只想要将文件添加到zip文件,而不保留路径。
我搜索了很多,但似乎没有找到任何方法这样做,也许我缺少明显的东西。
感谢
提供完整路径。这应该工作。不是从当前位置的相对路径。
例如,我给出下面的内容,我想将man5文件夹中的文件存档。
$ 7z a -tzip myzip.zip / home / pradeeban / Desktop / man4 / man5 / *
zip只包含文件,而没有目录。
我只给了相对路径。它有邮件中的目录。
$ 7z a -tzip myzip.zip Desktop / man4 / man5 / *
尝试使用Linux(Ubuntu 12.04)。不确定是否与Windows不同。
I am using 7z command line executable to zip files, but I see that while adding to an archive the path of the files is preserved in the archive.
So if I do
7z a -tzip myzip.zip dir1\dir2\*
the archive myzip.zip will contain the path dir1\dir2. I do not want this, rather I want only the files to be added to the zip file without the paths being preserved.
I searched quite a bit but do not seem to find any way of doing this, maybe I am missing something obvious?
Thanks
解决方案 Give the full path. That should work. Not the relative path from the current location.
For example, I give the below, where I want the files in the man5 folder to be archived.
$ 7z a -tzip myzip.zip /home/pradeeban/Desktop/man4/man5/*
The zip contained only the files, without the directories.
Then I gave only the relative path. It had the directories, inside the zip.
$ 7z a -tzip myzip.zip Desktop/man4/man5/*
Tried with Linux (Ubuntu 12.04). Not sure whether that differs from Windows.
这篇关于仅使用7z压缩文件,而不保留路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!