1

Using bash on OS X 10.10 I'm zipping a folder and saving it elsewhere using this:

_now=$(date +"%Y-%m-%d-%H-%M-%S")
pushd /Users/me/Documents/local-backups/writing
zip -r /Users/me/Documents/local-backups/writing/writing-bak-$_now.zip /Users/me/Dropbox/writing
popd

However my zipped file includes all the annoying directories above "writing" (i.e., from /Users/me/Dropbox/writing).

I saw the question and answer here:

Avoid unwanted path in Zip file

... but I couldn't see how the solution there could apply to my example where directories are far apart.

GMag
  • 11
  • 1
  • Why change directory, since you are using full paths in the `zip` command? If you change directory to `/Users/me/Dropbox/writing` you can simply zip the relative directory `.`, or use `*` if you don't want the `./` prefix. – AFH Dec 04 '14 at 21:40
  • I'm sorry, I don't understand. I've specified two directories because the file to be zipped is in one and the destination for the zip file is in another. What would be your alteration, so that I may understand? – GMag Dec 04 '14 at 21:48

1 Answers1

0

The penny dropped. It should be:

_now=$(date +"%Y-%m-%d-%H-%M-%S")
pushd /Users/me/Dropbox
zip -r /Users/me/Documents/local-backups/writing/writing-bak-$_now.zip ./writing/
popd
GMag
  • 11
  • 1