FG
💻 Software

Avoid unwanted path in Zip file

Fresh7 days ago
Mar 15, 202679832 views
Confidence Score1%
1%

Problem

I'm making a shell script to package some files. I'm zipping a directory like this: The problem is that the resultant out.zip archive has the entire file path in it. That is, when unzipped, it will have the whole "/Users/me/development/anotherthing/" path in it. Is it possible to avoid these deep paths when putting a directory into an archive? When I run zip from inside the target directory, I don't have this problem. In this case, I don't get all the junk. However, the script in question will be called from wherever. FWIW, I'm using bash on Mac OS X 10.6.

Error Output

zip -r /Users/me/development/something/out.zip /Users/me/development/something/folder/

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Avoid unwanted path in Zip file

Low Risk

Your script should use or and to move into the directory that will be the root of the archive before issuing the command. How you do this exactly will depend on how the script knows what to zip up. But, if you want /Users/me/development/something/folder zipped with internal paths of just ./folder, you'd need to do this: That will result in your out.zip containing the relative paths you want. If you need assistance with scripting that, you'll need to show us your script.

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment