Is it possible to copy a Symlink to a directory in Windows 7. When I try to copy a symlink'd directory, it tries to deep copy the contents to the location.
I don't know of a way to do it within Windows Explorer, but you can use
xcopy at the command line with the /b argument, see here.
use the following command in the elevated command prompt:
xcopy /b /i <source symlink name> <destination symlink name>
The output is 0 File(s) copied nevertheless the symlink is created in the destination. This is tested under Windows 7 and Windows 8.x but should work starting as of Vista
UPDATE: it works in Windows 10 as well
Use a program that supports them, obviously. Far Manager for example allows me to either copy symlinks as links or traverse them and copy their contents:
You can use Link Shell Extension for this, however the instructions are a bit convoluted. (for copying already-existing symbolic-links)
- Use its LSEConfig.exe utility to change the "Outer Junction/Symbolic Link" setting to "Splice".
- Right-click and "Pick Link Source" the parent folder of the sym-linked folder you want to copy.
- Go to the parent folder of the place you want to drop the sym-linked folder, and run "Drop As: Smart Copy".
- Rename the temporary parent "container folder" to the destination/real parent-folder name.
The procedure is somewhat of a hassle, so I'd recommend using xcopy or Far Manager instead. (haven't tried them yet, but I'm assuming they're more straight-forward for direct/single sym-linked-folder copying)
(Link Shell Extension is still worth getting, in my opinion, for the streamlined creation of sym-links, however.)
Far Manager was the only thing that worked. Thanks Joey.
For some reason Link Shell Extension either doesn't provide a way to copy sym links/junctions, or I'm too stupid to figure it out. Tried everything on the Drop As... menu.
With Far Manager, just hit Copy at the bottom of the interface, after making sure that the other window pane is pointed at your destination folder. It's that simple!
I copied my entire User folder! Some links you have to correct afterwards, like application data. If you have Link Shell Extension just right click and change the path in the Link context properties menu. Otherwise they will point to your old drive. Be sure to correct the ones inside application data,
Temporary Internet Files too. Be sure to TAKE OWNERSHIP before copying!
Also, you need to do this logged in to another Admin profile, or booted into another OS. If you're booted into another OS make sure the links point to the drive letter that the target OS wants, not the drive letter the current OS wants. For example my target OS is J:\users\Me. My Junctions there point to C:\users\Me because C:\ is the drive letter I'll be booted into. (Yes, clicking the links now will open your current OS's folder. Don't worry about it.)
There are Registry entries you have to change. See here.
Also I found a shell extension that might make this a bit simpler.
It's demonstrated on HowToGeek here
And the link to the shell extension itself is here
Unfortunately I haven't had a chance to test this myself because I need to do it on a server and I don't particularly want to fiddle around with shell extension on a production server - but I thought it might be useful.
This was done using Windows 10 Pro edition. However, I think it is the same on Windows 7 and Windows 8.
First, add the ability to create symlinks to your non-admin user account. This is found in the Local Security Policy (secpol) in "Security Settings>LocalPolicies>User Rights Assignment>Create symbolic links". By adding your non-admin user to this user rights setting, you are allowed to create symbolic links, a permission you need if you copy, and therefore create, a symlink.
Then do this in a command prompt window:
copy /L sourceLocation targetLocation
Here is a solution in one-line of Python that I copy-paste every time I need it:
import os, glob, shutil; [shutil.copy(f, '.', follow_symlinks=False) for f in glob.glob(r'c:\src_dir_containing_symlinks\*')]
Now in a more readable form:
SRC = r'c:\test' DST = '.' import os, glob, shutil for f in glob.glob(os.path.join(SRC, '*')): shutil.copy(f, DEST, follow_symlinks=False)