suppose i want to zip this dir 〔c:/Users/xah/ErgoEmacs_Source/ergoemacs/build-util/〕
and my i want the output dir to be 〔c:/Users/xah/xx2/〕
(my current dir could be anywhere. I'm calling zip in a elisp program) so i do
zip -r c:/Users/xah/xx2/build-util.zip c:/Users/xah/ErgoEmacs_Source/ergoemacs/build-util/
then zip will record the full path like this
adding: Users/xah/ErgoEmacs_Source/ergoemacs/build-util/ (stored 0%)
adding: Users/xah/ErgoEmacs_Source/ergoemacs/build-util/.svn/ (stored 0%)
adding: Users/xah/ErgoEmacs_Source/ergoemacs/build-util/.svn/all-wcprops (deflated 56%)
...
i want the paths to simply start with build-util.
note: i'm calling zip in a program (elisp) and i cant or don't want to use any concept of envirenment variable.
Is this possible with some zip parameter?
Use the -j or --junk-paths option in your zip command. -j --junk-paths Store just the name of a saved file (junk the path), and do not store directory names. By default, zip will store the full path (relative to the current directory). Hope this helps. (cd directory && zip -r ../out.zip .)
When I try to zip it, it ends creating a zip archive with the v folder instead of the contents of it (the sub directories and files) How can I avoid this? Use the -j or --junk-paths option in your zip command. -j --junk-paths Store just the name of a saved file (junk the path), and do not store directory names.
cd folder zip -r ../zipped_folder.zip . I use -r option, the "zip filename" and the list of items I want to add into it. Refering to --help option we get: You can go into folder that contains the files and directories you want to zip in. The run the command: zip -r filename.zip ./*
I use -r option, the "zip filename" and the list of items I want to add into it. Refering to --help option we get: You can go into folder that contains the files and directories you want to zip in. The run the command: zip -r filename.zip ./* The result is a filename.zip containing everything into the directory you ran the command.
Oddly enough, your best option may be to use jar from the Java JDK.
jar -cMf c:/Users/xah/xx2/build-util.zip -C c:/Users/xah/ErgoEmacs_Source/ergoemacs/build-util/ .
the "-M" tells jar not to create a manifest file and the -C tells it to change directories before beginning zipping files up. The documentation I based this off of is here: http://download.oracle.com/javase/tutorial/deployment/jar/build.html
One of my favorite bash functions is pushd, it saves the dirrectory you are currently in and moves you to the directory you specify. The reciprocal function is popd, it moves you back to the directory you were in before pushd. For example you do
pushd c:/Users/xah/ErgoEmacs_Source/ergoemacs
zip -r c:/Users/xah/xx2/build-util.zip build-util/
popd
I think you wind up with what you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With