Page 1 of 1

Label or tag hardlinks

Posted: 14 Feb 2020 15:46
by Gary
I divide my client files into subdirectories by standard topics (Correspondence, Research, Pleadings, etc). However, I also like to keep all files for a particular client in a subdirectory for that particular client (named ALLFILES-(client number). To avoid having multiple copies of files on my drive, I create hard links in the ALLFILES subdirectory.

I know how to use XY's label feature to give all hard link files a color code, but it does so for both the original file and the hard link in the ALLFILES folder.

I want to either auto label the original file with one color and the link with another, or if that is not possible or too slow (I read that labeling hadlinks slows down the system), then maybe add XY tags to distinguish the files (e.g., "orig file" for the original, "link file" for the hard link) with a script.

That way I would always know not only what files had hardlinks but also what files were originals and what files were just the hardlinks.

Thanks for any help you can offer.

Re: Label or tag hardlinks

Posted: 14 Feb 2020 16:04
by highend
How exactly is the hard link created?

If I do this with the new() command from inside XY I have no problems to give the hardlink and the file it points to, two different color labels...
2020-02-14_160502.png
2020-02-14_160502.png (2.13 KiB) Viewed 3031 times
Apart from that, get https://docs.microsoft.com/en-us/sysint ... /findlinks
register it once, use it with runret(), parse the output and tag both files appropriately?

Re: Label or tag hardlinks

Posted: 14 Feb 2020 18:29
by Gary
you lost me with the suggestions you gave, but to answer your question about creating the hard links - before installing XY I created hardlinks with the Link Shell Extension https://schinagl.priv.at/nt/hardlinkshe ... nsion.html

After installing XY I created hardlinks using XY's copy then past as, then past as hardlink.

Re: Label or tag hardlinks

Posted: 14 Feb 2020 18:45
by Gary
If I use a Color Filter like this "prop:#HardLinks: > 1" then both the original file and the hardlink are shown in that color filter.

Re: Label or tag hardlinks

Posted: 14 Feb 2020 18:55
by highend
Select all files in the "ALLFILES" folder (in other words, all hardlinks) and execute this script:

But before you do that, adapt the path to FindLinks64.exe in it...

Only the last item that findlinks lists in its output will be tagged! Didn't test it with multiple hardlinks to one file...

Code: Select all

    $tool = "D:\Tools\@Command Line Tools\FindLinks\FindLinks64.exe";
    foreach($file, <get SelectedItemsPathNames <crlf>>, <crlf>, "e") {
        $result = trim(runret("""$tool"" -accepteula -nobanner ""$file"""), <crlf>);
        if (regexmatches($result, "Links:.*?[1-9]")) {
            $hardlink = gettoken($result, 1, <crlf>, "t");
            $original = gettoken($result, -1, <crlf>, "t");
            tagitems("tag", "link file", $hardlink);
            tagitems("tag", "orig file", $original);
        }
    }

Re: Label or tag hardlinks

Posted: 14 Feb 2020 20:29
by Gary
Thanks for the quick reply and code.

When I run the script only the last selected file gets the "link file" tag.

So, e.g., if I select files 1 to 10, then run the script, only file 10 get the "link file" tag.

If I then select file 1 to 9, only 9 gets the "link file" tag.

Re: Label or tag hardlinks

Posted: 14 Feb 2020 21:03
by highend
Replace <curitem> with $file

Re: Label or tag hardlinks

Posted: 14 Feb 2020 21:22
by Gary
i'm not sure what you mean by that

Re: Label or tag hardlinks

Posted: 14 Feb 2020 22:28
by admin
I think he did that (Replace <curitem> with $file) already in the code shown in viewtopic.php?p=176329#p176329

Re: Label or tag hardlinks

Posted: 14 Feb 2020 22:45
by Gary
I'm not sure what happened but now it seems to work - Thank you so much for taking the time to apply your knowledge and skill to my question.