Label or tag hardlinks

Discuss and share scripts and script files...
Post Reply
Gary
Posts: 18
Joined: 14 Feb 2020 15:29

Label or tag hardlinks

Post 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.

highend
Posts: 13308
Joined: 06 Feb 2011 00:33

Re: Label or tag hardlinks

Post 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 3018 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?
One of my scripts helped you out? Please donate via Paypal

Gary
Posts: 18
Joined: 14 Feb 2020 15:29

Re: Label or tag hardlinks

Post 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.

Gary
Posts: 18
Joined: 14 Feb 2020 15:29

Re: Label or tag hardlinks

Post 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.

highend
Posts: 13308
Joined: 06 Feb 2011 00:33

Re: Label or tag hardlinks

Post 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);
        }
    }
One of my scripts helped you out? Please donate via Paypal

Gary
Posts: 18
Joined: 14 Feb 2020 15:29

Re: Label or tag hardlinks

Post 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.

highend
Posts: 13308
Joined: 06 Feb 2011 00:33

Re: Label or tag hardlinks

Post by highend »

Replace <curitem> with $file
One of my scripts helped you out? Please donate via Paypal

Gary
Posts: 18
Joined: 14 Feb 2020 15:29

Re: Label or tag hardlinks

Post by Gary »

i'm not sure what you mean by that

admin
Site Admin
Posts: 60526
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Label or tag hardlinks

Post by admin »

I think he did that (Replace <curitem> with $file) already in the code shown in viewtopic.php?p=176329#p176329

Gary
Posts: 18
Joined: 14 Feb 2020 15:29

Re: Label or tag hardlinks

Post 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.

Post Reply