Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 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 (so if there is a symlink name "foo" which points to "C:\stuff\foo" I want it to include the "C:\stuff\foo" stuff in the archive in place of foo, not a "0 byte" symlink...

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... I'm thinking mayby a program that creates a staging folder with the real files in it then passes that to 7zip, or just an archiver that does handle them better?

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

EDIT:

dir command output for a smaller test directory:

C:\...>dir
 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.

share|improve this question
    
Which OS are you using? –  Charles Gargent Apr 8 '10 at 21:27
1  
Doesnt the "windows" tag suggest that im using, well windows... –  Fire Lancer Apr 8 '10 at 21:39
1  
Ok, What version of windows are you using? –  Charles Gargent Apr 8 '10 at 21:40
    
@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 '10 at 21:52
    
@Fire Lancer: Please check and specify whether the "symbolic links" you describe are really symbolic links, or rather junction points (different, but related). That makes a difference (see hova's answer). –  sleske Apr 8 '10 at 21:59
show 4 more comments

2 Answers

up vote 2 down vote accepted

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

share|improve this answer
add comment

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.

share|improve this answer
    
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? –  Fire Lancer Apr 8 '10 at 21:41
    
-1 How does that solve the problem? You just describe how to create symbolic links. –  sleske Apr 8 '10 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 '10 at 21:55
    
7zip archives SYMLINKD (mklink) directories! –  hova Apr 8 '10 at 21:57
    
@hova: OK, now I see (downvote removed). If 7zip can actually archive targets of symbolic links, this makes sense. –  sleske Apr 8 '10 at 21:57
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.