Duplicate files can secretly occupy a lot of space on your Windows machine. From photos, videos, documents to software files that you might have copied many times, all of these occupy unnecessary space and lead to difficulties in managing files. Instead of deleting duplicate files, there is another way through which duplicate files can be replaced with hard links in Windows. In this case, you get access to all of the files from their respective locations while having just one copy of the files stored on disk.
This guide covers everything related to replace duplicate files with hard links Windows, hard link creation, advantages, disadvantages and how to create them.
What Are Hard Links in Windows?
A hard link is a new directory entry that refers to the same actual file on an NTFS disk.
For example:
- File A: 500 MB
- File B: 500 MB (duplicate)
Generally, what would happen is that they combined take around 1 GB of space.
But, what would happen if I replace the duplicate with a hard link:
- File A stays
- File B is a hard link to File A
Here, a twist happens that both files will be shown in File Explorer, but one with hard link will be consuming space and other one not. Any changes made to the file using either filename will result in changes to the same file as both filenames refer to the exact same data. On the other hand, you can check the article on how to find duplicate files using Reference folder.
Why Replace Duplicate Files with Hard Links?
There are various reasons why most people opt for this technique.
Saves Hard Drive Space
The actual file is present once.
Preserves File Structure
Software will continue using files from their respective folders.
Quicker Process
No need to make changes in software and folder links.
Easy Access
Most software is unable to differentiate between a file and a hard linked file.
Important Conditions Prior to Making Hard Links
Before creating hard links in order to delete duplicate files on your computer running Windows, you must have the following:
- Ensure both files are identical.
- Both files should be on an NTFS partition.
- Files should be present on the same drive.
- Hard linking is done for files, not folders.
- Make sure to back up important files.
#1: Replace Duplicate Files with Hard Links Using Command Prompt
This is Microsoft’s native way.
Step 1: Find Identical Files
First, you need to locate the two identical files that are on an NTFS partition.
Example:
D:\Projects\File1.docx
D:\Backup\File1.docx
Step 2: Remove One Copy
Next, you can remove the identical file as per your choice.
In the example above:
D:\Backup\File1.docx
Step 3: Launch Command Prompt as Administrator
Look for:
Command Prompt
And click:
Run as Administrator
Step 4: Create the Hard Link
Enter the following command line:
mklink /H "D:\Backup\File1.docx" "D:\Projects\File1.docx"
Alternatively, you may use fsutil.exe utility:
fsutil hardlink create "D:\Backup\File1.docx" "D:\Projects\File1.docx"
The system will create a new entry in the directory that will refer to the file, but not contain it.
Step 5: Check
Open both locations.
You will find:
- Both files reside in their places.
- Open any of them to see identical content.
- Storage space is taken by one file only.
#2: Replace Duplicate Files with Hard Links Using PowerShell
By using this approach, you can replace the duplicate files with Hard links but it is a bit technical. Here are the following process:
Step 1
At first, Launch PowerShell with Administrative rights.
Step 2
Next, remove the duplicated file.
Step 3
Execute:
New-Item -ItemType HardLink -Path "D:\Backup\File1.docx" -Target "D:\Projects\File1.docx"
Step 4
Ensure that both files work fine.
PowerShell is a handy tool when automation of linking files is required.
#3: Replace the Duplicate Files using Automated Software
Finding many files manually could take lots of time. For those seeking a more effective way, SysTools Duplicate Finder Software provides the most convenient solution through scanning the storage places for similar files using effective comparison techniques. The software will help you identify the duplicates easily, which is very important in dealing with redundant files.
How to Confirm Hard Links Were Created?
Windows has a tool for listing all hard links that point to a file.
Open the Command Prompt:
fsutil hardlink list "D:\Projects\File1.docx"
Now, the output of this script will show all the paths pointing to that particular location of the same file record.
Hard Links vs Symbolic Links
| Feature | Hard Link | Symbolic Link |
| Same Drive Required | Yes | No |
| Supports Files | Yes | Yes |
| Supports Folders | No | Yes |
| Breaks if Original Deleted | No | Yes |
| Uses Same Physical Data | Yes | No |
Usually, what happens is – Hard links directly give the reference to the file’s data, while symbolic links point to the file path.
Difference In Appearance: The most noticeable difference from the user perspective is how these two link types look in Windows Explorer.
- With a hard link, the linked file will appear just like a regular file. There won’t be any shortcut arrows or other visual cues which indicate the presence of a hard link.
- On the contrary, the symbolic link will usually have a link/shortcut icon which makes it obvious to the user that it does not actually contain any data. This is one of the reasons why people prefer to use hard links when there are duplicate files which need to be transparent for users and applications.
Frequently Asked Questions
Q. Can Windows create hard links for duplicate files automatically?
Ans. Windows allows creation of hard links but does not search for duplicates and create hard links to save storage space. However, for automation, you may require 3rd party software to hard links instead of duplicate files.
Q. Does hard links consume less storage space in comparison to actual data?
Ans. Yes, it saves a significant amount of space as several files point to a single data copy of the file.
Q. Can I create hard links to the files in USB drives?
Ans. If the USB drive is formatted using NTFS, then yes.
Q. Are hard links reliable?
Ans. If the files are indeed identical and you know that any changes applied via one hard link affect all other names.
Q. Can hard links be reverted to normal?
Ans. Yes. Deletion of a hard link deletes just the directory entry. The data will be available until another hard link is left.
Final Takeaway
Learning how to replace duplicate files using hard links in Windows will be a good strategy in helping to recover the disk space used without changing the existing folder hierarchy. With hard links, several filenames will refer to the same copy of a file thus saving the wasted space and still having easy access to the file from various places. Having the knowledge of how NTFS hard links work when removing duplicates will be useful for either using Command Prompt, PowerShell, or the dedicated file duplicate management tool.