windowsfilesystemshyperlink

How to delete file along with all hard links on windows?


This question's context is the Windows operating system...XP on up to Win 7/8.

If you create a file on a drive and then create one or more hard links to that file, then if you delete the original file the file still resides on the disk since the hard links still refer to that file.

Is there some simple way (delete option?) to be able to remove the file and all of the hard links without having to search around for the hard links (not sure how you even find those from a simple windows user interface standpoint...I know you can do it with programming code, but I am looking for a user-level solution within the standard operating system user interface)?

Thanks!

EDIT:

I found this question/answer that discusses how to programmatically use c++ to find additional links to the file, but still searching for a standard windows UI or command line method. How to find all hard links to a file in Windows starting from XP in C++

Also found this link on superuser.com that doesn't give me much hope. Help! https://superuser.com/questions/366739/how-can-i-find-hard-links-on-windows


Solution

  • There is a free utility called ln.exe that has a --list option that finds all of the hard links related to a given filename. Its download also comes with a batch file (DeleteAllHardlinks.bat) that will automatically delete all of the hard links to a given file name.

    This pretty much addresses my need, so I will consider this a good answer.

    Here is a link to the page for this utility. Hope someone else can benefit from this in the future!

    http://schinagl.priv.at/nt/ln/ln.html