Plugin to quickly locate all files hard linked together

May 20, 2008
3,515
4
Elkridge, MD, USA
I use many hard-linked files for various purposes, and at various times need to find all of a files siblings. Due to NTFS design, this requires an exhaustive search of the FS. I wonder if one could use a FOLDERMONITOR thread to maintain a database of hard-linked objects (one would need to build the database on first activation, or to refresh it). This database would also be very valuable for backup, migration, etc.
 
I can't help with code, but possibly an alternative suggestion.

I use a number of different image editing programs such as PaintShop Pro and Photoshop Elements. Those programs include a huge number of scripts, bitmaps, sample images, etc. I have 60GB SSD's for my C:\ drive and those clutter up the drive, so I use junctions to move all those to a different physical drive. I normally use junctions for folders, not individual files.

Whenever I create a junction, I rename the original folder by adding a minus, e.g., MSO Cache => -MSO Cache. In the parent folder I add a file called JUNCTION LIST.TXT That contains entries in the format:

C:\MSO Cache was replaced with a junction to S:\<whatever>\MSO Cache
MKLINK <the specific code that was used to create the junction>

I then use that code to actually create the junction.

In the junction target I also put the same file JUNCTION LIST.TXT

If you want to, you can put the contents of all the JUNCTION LIST.TXT files into a single file so you'll have a record in one place.
 
If you are just looking at file hard links... not worried with directory junctions and such... then findlinks can do it, so I can't image why a plugin could not. Then again if findlinks works for you no need for a plugin unless you just want a cleaner output withOUT any processing of the output of findlinks... or just want a challenge. :)

https://technet.microsoft.com/en-us/sysinternals/hh290814?f=255&MSPPError=-2147217396

[C:\Utils]FindLinks.exe "c:\Program Files (x86)\JPSoft\TCMD15\tcc.exe"

FindLinks v1.0 - Locate file hard links
Copyright (C) 2011 Mark Russinovich
Sysinternals - www.sysinternals.com

c:\program files (x86)\jpsoft\tcmd15\tcc.exe
Index: 0x0007FA3B
Links: 4

Linking files:
c:\Program Files (x86)\JPSoft\TCMD15\4nt.exe
c:\Program Files (x86)\JPSoft\TCMD15\test1.exe
c:\Program Files (x86)\JPSoft\TCMD15\test3.exe
c:\Program Files (x86)\JPSoft\TCMD15\test2.exe​

A more extensive util is ln from:

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

[C:\Utils]ln -l "c:\Program Files (x86)\JPSoft\TCMD15\tcc.exe" | tail /n+2
c:\Program Files (x86)\JPSoft\TCMD15\4nt.exe
c:\Program Files (x86)\JPSoft\TCMD15\test1.exe
c:\Program Files (x86)\JPSoft\TCMD15\test3.exe
c:\Program Files (x86)\JPSoft\TCMD15\test2.exe
There is also a graphical shell extension for the ln util above, but I have not used it:

http://schinagl.priv.at/nt/hardlinkshellext/hardlinkshellext.html#linkproperties
 
Last edited:
I now have LINKSTO in my SYSUTILS plugin. Doing it for one file (as in my previous post) was almost trivial.
Code:
p:\4sysutils\release> linksto "c:\Program Files\Common Files\microsoft shared\DAO\dao360.dll"
\Program Files\Common Files\microsoft shared\DAO\dao360.dll
\Windows\winsxs\x86_microsoft-windows-m..s-components-jetdao_31bf3856ad364e35_6.1.7600.16385_none_7b8c1dc4ef873d90\dao360.dll
Finding all such on a volume is a different story. I've written a version of DU.EXE which can output a list of them to a file (whick makes sense after it's sorted). That's very slow and I doubt it can be made fast ... you have to plow through all the files. I'll try adding a @LINKSTO[] function. If that works out, the user might try something like ...
Code:
do f in /s /a:-d /d"g:\" * ( if %@LINKSTO["%@full[%f]"] GT 1 linksto "%@full[%f]" )
... or something like that.
 
Yeah, that works and it isn't too bad. It finds about 1000 in c:\ in about 17 seconds.

Occasionally, access is denied. Should I print an error message or silently continue?
 

Similar threads