I used a windows 7 utility to delete exact byte per byte duplicate files and replace them with a symbolic link before I knew that the symbolic link type is not allowed in our corporate domain. I need a way to undo all the changes made but the program doesn't have a way to do this.

Is it possible to write a script of some sort that would find the links, find the file, remove the link and copy the file back to the folder and rename it to match the links name? Or maybe a piece of software that does this?

Thanks for any and all help.


This the type of situation where having a well planned and maintained backup strategy really pays off. If that's the case at your company, use it.

What you did is a poor way to save space. Consider the following use case:

  1. User copies files from Deptx share in preparation to do work on them
  2. You toss her copies and create symlinks to the origins
  3. She modifies the originals which were still required by others for their work
  4. ...

If you're that storage poor, it's best to draft a business plan for the purchase of additional storage. Ideally a solution that supports block level deduplication. If your existing appliance offers deduplication you could have submitted a change request for approval to implement it - but that time is passed.

A note for the future. As a storage admin you need to inform business when it's time to expand storage, which is usually when it's about half full. When it's 70% full you can start pulling the fire alarm daily until they assign budget. If that doesn't happen it's time to inform them in a very frank meeting that they're risking the business. Data is the core of modern business.

You can identify all of the symlinks with:

C:\Users\user>dir /AL /S C:\ | find "SYMLINK"
07/14/2009  01:08 AM    <SYMLINKD>     All Users [C:\ProgramData]

# Only one result in on my Windows 7 host, and it's a system default.
# There are likely more in Windows Server OSs.
# Cmd Explained:
# /AL   A Lists file with attribute:L (Symlinks and dir junctions)
# /S    Do recursively
# C:\   Drive to scan

'All Users' is the symlink 'C:\Users\All Users', which targets 'C:\ProgramData'. Note that the output of the above command does not give the full path to the symlink, which you need.

<<< STOP >>> If the number of symlinks is fewer than a thousand, it may be worth strongly considering manually replacing them with their target files.

You could use NTFSLinksView. It appears to be able to export data which includes the full target and symlink paths. http://www.nirsoft.net/utils/ntfs_links_view.html

Once you have these values, you can loop through them with this bit of Powershell. Modify the delim to whatever the program outputs. The example sets spaces as the delimiter. If it uses commas, then use: ','. Make sure the cvs has only the Link and Target data. In that order.

Note: This does not preserve default symlinks...

Import-CVS -Delim ' ' -Path input.cvs -Header Link,Target | ForEach-Object {
cmd /c rmdir $Link
Copy-Item $Target $Link

WARNING: This is untested and has potential to do even more damage... Use at own risk. If no prior backups exist, and you've arrived at this outcome, do a backup before going any further.

| improve this answer | |
  • Thanks for the help. Thanks for reiterating my boss's butt kicking speech from this morning. – DawnTreader May 26 '15 at 6:57
  • Yea, it sucks. I know you know, but that's more for any other readers that come across this. – Alex Atkinson May 26 '15 at 7:09
  • 1
    I forgot that this is also for other people to learn from, hopefully they are looking at it BEFORE they do what I did. This situation has made us take a hard look at the folder in question and revaluate its use. In the past this folder was there to allow employees to share, on a temporary basis, a file that normally would be inaccessible to other employees in other departments. This "common" folder became a dumping ground for a lot of things including personal pictures and videos. There are 2 employees who do most of their work out of this folder and the reason why we have to do a "rollback". – DawnTreader May 26 '15 at 7:26

This problem is not because of a domain policy. It is because of a windows update that broke symbolic links. this thread helped me understand the actual problem. After uninstalling the update, and using a command prompt to do this command:

fsutil behavior set SymlinkEvaluation L2L:1 R2R:1 L2R:1 R2L:1

I was able to copy the top folder to a local USB drive and retrieve the original files as files as the original name and undo most of the "damage" I did.

For those who uninstall the update and use the command above, you have to do both things on both the machines for the links to work correctly. I was only able to do it on the computer I had originally used to de-dupe the folder. I am not even sure if I had to do either action in order to copy the files to a USB drive and have the links behave so that I got back the original files. At this point I corrected the problem and do not need to pursue the coding I was doing further.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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