MacOS – How to copy a zip with symbolic link in OS X

macossymlinkzip

I am trying to create a zip file with a symbolic link.
I have a subfolder in my mainfolder with some.bundle. I create symbolic link for this some.bundle which is placed in another subfolder of mainfolder.
I then zip it using Terminal.

My problem is when I open the zip via Terminal and then try to copy the bundle to some other folder using the symbolic link. It doesn't works.

It gives an error something like this..

cp:/path to my subfolder with bundle symbolic link/some.bundle No such file or directory

Best Answer

I did the following to check/solve this (but I don't really know if I understand the question/the problem correctly):

enter image description here

  1. Create a file.bundle with

    touch /Users/user/temp/step1/file.bundle
    
  2. Create a symlink in another folder

    ln -s /Users/user/temp/step1/file.bundle /Users/user/temp/step2/  
    

    the (re-transcribed) hex content of the symlink is:

    /Users/user/temp/step1/file.bundle 
    
  3. Zip the symlink

    zip -y /Users/user/temp/step3file.bundle.zip /Users/user/temp/step2/file.bundle`
    
  4. Create a folder (step4), cd into it and unzip step3file.bundle.zip

    mkdir /Users/user/temp/step4
    cd /Users/user/temp/step4
    unzip /Users/user/temp/step3file.bundle.zip  
    

    the (re-transcribed) hex content of the unzipped symlink in /Users/user/temp/step4/Users/user/temp/step2 is still:

    /Users/user/temp/step1/file.bundle 
    
  5. Copy file.bundle in folder step1 using the symlink in a subfolder of folder step4 into folder step5

    cd /Users/user/temp/step4/Users/user/temp/step2
    cp file.bundle /Users/user/temp/step5
    

The above steps work. You probably zipped the folder containing the symlink and/or got some paths/commands (and maybe some options) wrong.