Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
402 views
in Technique[技术] by (71.8m points)

command line - Compressing only files using 7z without preserving the path

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 dir1dir2*

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?

Thanks

question from:https://stackoverflow.com/questions/10753667/compressing-only-files-using-7z-without-preserving-the-path

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...