I'm trying to compress a folder into a .7z archive. This folder contains symbolic links to some other stuff outside the folder (both directories and files).

Apparently 7zip just archives the link itself which is not what I intended. Is there a way to tell 7zip that I want it to archive the stuff that it links to, not the link itself? (That is if there is a symlink name foo which points to C:\stuff\foo, I want it to include the C:\stuff\foo directory in the archive in place of foo, not a 0-byte symlink.))

Is there any reasonable workaround apart from adding the files and folders in question? There are about 10,000 files referenced via symlinks so adding them all individually would take hours… Maybe there's a program that creates a staging folder with the real files in it and then passes that to 7zip. Or just an archiver that does handle symlinks better.

I'm running Windows Vista. All the links are symbolic links (eg created with mklink link target and mklink /D link target).


dir command output for a smaller test directory:

 Volume in drive C is OS
 Volume Serial Number is 0A3D-CD6E

 Directory of C:\...

09/04/2010  18:12    <DIR>          .
09/04/2010  18:12    <DIR>          ..
09/04/2010  18:10               975 real file.txt
09/04/2010  18:11    <SYMLINK>      test file.txt [..\test file.txt]
               2 File(s)            975 bytes
               4 Dir(s)   5,214,355,456 bytes free

Creating a 7z archive of that with 7zip results in real file.txt being included, but test file.txt is added as a 0 byte file, although the file linked to does exist and is 50KB.

  • Which OS are you using? Apr 8, 2010 at 21:27
  • 2
    Doesnt the "windows" tag suggest that im using, well windows... Apr 8, 2010 at 21:39
  • 1
    Ok, What version of windows are you using? Apr 8, 2010 at 21:40
  • 1
    @Fire Lancer: Generally, it's a good idea to repeat any information from the tags in the text. Easier to read, and not everyone looks at he tags (as they're at the bottom). Plus, the tags can be prone to misunderstandings. E.g., I might be on Linux but want to interoperate with Windows, so I tag my question "windows".
    – sleske
    Apr 8, 2010 at 21:52
  • 1
    Well, it would appear that 7z archives <SYMLINKD> and <JUNCTION> directories but not <SYMLINK> files, so i guess if you can sneak all your files into a directory and symlink that it would work
    – hova
    Apr 9, 2010 at 20:45

3 Answers 3


Apparently 7zip just archives the link it's self which is not what I intended. Is there a way to tell 7zip that I want it to archive the stuff that it links too, not the link its self

No, apparently not (unfortunately). There is actually a bug report on 7zip requesting this: http://sourceforge.net/tracker/?func=detail&aid=2846755&group_id=14481&atid=114481 but it was opened in August 2009 and not touched since :-/.

Failing that is there any reasonable around it, apart from adding the files and folders in question? Including the stuff through the symlink there's like 10 000 files, the large proportion of which are via symlinks so adding them all individually would take hours...

Well, if you have enough space (and time), you can make copy of the folder, replacing the symlinks with their targets. You can e.g. use Robocopy and its switch /sl:

/sl Copies the symbolic link instead of the target

Note: Just to avoid confusion, note that the Linux build of p7zip (a port of 7zip) also has a binary 7z which does support archiving the file a symbolic link points to (switch -l). However, 7zip on Windows does not have this switch.

  • Because this is the approved answer, want to point that actual 7zip does it by -l switcher. zip and gzip does too with their specific commands.
    – m3nda
    Mar 5, 2015 at 14:21
  • @erm3nda where do you see this switch? Please, provide the reference.
    – mark
    Apr 29, 2015 at 15:22
  • linux.die.net/man/1/7z There is a option l, and there is also a switch with the same letter. I've note that this option is not present at the Windows version of the software.
    – m3nda
    Apr 30, 2015 at 18:48
  • @erm3nda: Yes, but that is p7zip, a port of 7zip. Thanks for pointing it out; I updated my answer.
    – sleske
    May 1, 2015 at 7:38
  • Thank you too. Can't believe that Windows is missing this feature. Even if the symlinks on Windows are quite diferent, don't figure out why is hard to make it work.
    – m3nda
    May 1, 2015 at 16:57

As of 2019, 7-Zip has resolved this issue in Windows. The latest version has a checkbox to include symlinks in TAR and WIM archives and it works great!

Store Symbolic Links in TAR

Store Symbolic Links in WIM

  • 1
    Where is this checkbox? It's not showing up in the archive window. What version is this for? Jul 10, 2020 at 17:10
  • 1
    @BramVanroy - are you sure you selected TAR or WIM for the archive format? It is showing up for me even on 7-Zip 15.05
    – Kidburla
    Sep 17, 2020 at 17:23
  • 2
    tar and wim do copy the files / directories, but don't compress. So after tar-ing, you can then .zip or .7z the tar file. Turns out a bit easier than doing a copy to a new target first.
    – simo.3792
    May 11, 2021 at 4:58
  • 5
    Note: in order to get the target file / directory - not the link - you need to CLEAR the check box, not tick it.
    – simo.3792
    May 11, 2021 at 4:59
  • 1
    it works, but if you use junction file, 7zip will convert to symbolic file.
    – netawater
    Jun 25, 2021 at 3:21

If you are using Vista and above, remove the symlinks and replace them with mklinks

mklink /D Directory FullPathToRealDirectory

Note that mklink is pretty powerful and can include links to network shares and the like.

Since there seems to be some confusion on this, allow me to clarify. I'm assuming the OP is actually talking about Junctions as illustrated here http://en.wikipedia.org/wiki/NTFS_junction_point. Mklink does not make junctions. It makes TRUE symbolic links and I tried it myself and 7zip respects them perfectly. Also, you need to be administrator to create mklink symbolic links.

 Directory of C:\temp\t

04/08/2010  04:50 PM    <DIR>          .
04/08/2010  04:50 PM    <DIR>          ..
04/08/2010  04:31 PM    <SYMLINKD>     GB [c:\users\testuser]    <-- created by mklink
04/08/2010  04:50 PM    <JUNCTION>     GB2 [\??\c:\users\testuser] <-- created by junction
04/08/2010  04:29 PM                 8 test.txt

7zip will archive GB, but it will NOT archive GB2. EDIT: Actually further testing shows that 7zip WILL archive both directories using version 4.65. So I have no clue what the problem is.

  • 1
    Given all the orig symlinks were made with the Microsoft API's and mklik in the first place, what does this solve apart from remake the same thing? Apr 8, 2010 at 21:41
  • 3
    -1 How does that solve the problem? You just describe how to create symbolic links.
    – sleske
    Apr 8, 2010 at 21:41
  • @hova: Yes, that is all true (though MS usually only calls the symbolic links "symbolic links"; junctions are never referred to as "symbolic links"). But how does this relate to the question?
    – sleske
    Apr 8, 2010 at 21:55
  • 7zip archives SYMLINKD (mklink) directories!
    – hova
    Apr 8, 2010 at 21:57
  • 1
    I just did some testing with 7zip v15.14 (64 bit) on Windows 7, and it seems that 7zip now follows directory symlinks but only stores an empty file for file symlinks -- which is not very useful. May 6, 2016 at 15:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .