仅使用 7z 压缩文件而不保留路径 [英] Compressing only files using 7z without preserving the path
问题描述
我使用 7z 命令行可执行文件来压缩文件,但我看到在添加到存档时,文件的路径保留在存档中.
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.
所以如果我这样做
7z a -tzip myzip.zip dir1dir2*
存档 myzip.zip 将包含路径 dir1dir2.我不想要这个,而是我只想将文件添加到 zip 文件中而不保留路径.我搜索了很多,但似乎没有找到任何方法来做到这一点,也许我遗漏了一些明显的东西?
the archive myzip.zip will contain the path dir1dir2. 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?
谢谢
推荐答案
给出完整路径.那应该有效.不是从当前位置的相对路径.例如,我给出了下面的内容,我希望将 man5 文件夹中的文件存档.
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.
然后我只给出了相对路径.它有目录,在 zip 里面.
Then I gave only the relative path. It had the directories, inside the zip.
$ 7z a -tzip myzip.zip Desktop/man4/man5/*
在 Linux (Ubuntu 12.04) 上尝试过.不确定这是否与 Windows 不同.
Tried with Linux (Ubuntu 12.04). Not sure whether that differs from Windows.
这篇关于仅使用 7z 压缩文件而不保留路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!