3

I'm trying to work with backups and new versions of backups and I want to check if files listed in a directory are already hardlink alias to some file or if they are the last link to that content.

The objective is to go to a directory, then ask which files are the only hard link and which files are not the only hard link without having to ask every single one individually.

To ask each one individually, I could use

fsutil hardlink list

But I would have to do that 1 by 1.

Any ideas on how to do that?

brunoais
  • 232

3 Answers3

0

You can use finddupe.exe to list all files in a directory with the hardlink count. But apparently it's not compatible with non-ASCII characters in filenames and a port can be found here.

Find single Files:

finddupe.exe -v -listlink *.* | find /I "Hardlinked (1 links) node="

or files with multiple hardlinks:

finddupe.exe -v -listlink *.* | find /V /I "Hardlinked (1 links) node="


I was looking for such a solution several times in the last years but never stumbled upon your question. Thus:

How to list / display / show number / count of hardlinks of all files in a directory?

Limer
  • 471
0

To specifically answer the Subject line, you can use PowerShell and Select-Object as follows:

PS> dir | select Name, LinkType, Target

Where select is an alias for Select-Object

Output:

Name                LinkType     Target
----                --------     ------
hardlinked_file.txt HardLink
regular_file.txt
symlinked_file.txt  SymbolicLink c:\_t\test.txt

Note: Hard Links in Windows do not have the concept of a Target as they are simply file system pointers to the same object with no instance being considered a Parent. Coming from *Nix, I find this an unfortunate design decision but I guess it can have advantages I can't grok at this time.

0

I made a cmd script that solves that issue.

Most help is in the comments
If you still need help, make a question issue in the gihub repo.

https://raw.githubusercontent.com/brunoais/cmd-dir-hardlinks/master/listHardLinks.bat

brunoais
  • 232