Linked files with hard link
Linked files with hard link
There is a utility FindLinks from sysinternals that displays all files associated with a hard link.
Is there such a possibility in the XYplorer? So that when you select a file with a hard link, all associated files are displayed.
Is there such a possibility in the XYplorer? So that when you select a file with a hard link, all associated files are displayed.
Re: Linked files with hard link
No, because fsutil would need to be invoked to get that info
You can see where a file points to but that requires hovering over a hardlink, not its source...
Code: Select all
$results = trim(runret("""fsutil"" hardlink list ""<curitem>""", , 65001), <crlf>);
$cntResults = gettoken($results, "count", <crlf>);
if ($cntResults >= 2) {
$drive = gpc(<curitem>, "drive") . ":";
$hardlinks = gettoken($results, $cntResults - 1, <crlf>, , 1);
$hardlinks = regexreplace($hardlinks, "^(.)", $drive . "$1");
$header = "Hardlink(s) to <curitem>";
$output = $header . <crlf> . strrepeat("=", strlen($header)) . <crlf> . $hardlinks;
text $output;
}
One of my scripts helped you out? Please donate via Paypal
Re: Linked files with hard link
Thank you. Works.
Last edited by zakoul on 21 Jul 2021 11:23, edited 1 time in total.
Re: Linked files with hard link
If there are no hardlinks pointing to the selected file, no, nothing will happen
One of my scripts helped you out? Please donate via Paypal
Re: Linked files with hard link
The last link does not display
Re: Linked files with hard link
Yeah, fsutil is a bit weird sometimes (at one time the source file is listed first, on other occasions as the last entry)
This should avoid it:
This should avoid it:
Code: Select all
$results = runret("""fsutil"" hardlink list ""<curitem>""", , 65001);
$escaped = regexreplace(substr(<curitem>, 2), "([\\.+(){\[^$])", "\$1");
$results = trim(regexreplace($results, "^$escaped(\r?\n|$)"), <crlf>);
$cntResults = gettoken($results, "count", <crlf>);
if ($cntResults >= 1) {
$drive = gpc(<curitem>, "drive") . ":";
$results = regexreplace($results, "^(.)", $drive . "$1");
$header = "Hardlink(s) to " . quote(<curitem>);
$output = $header . <crlf> . strrepeat("=", strlen($header)) . <crlf> . $results;
text $output;
}
One of my scripts helped you out? Please donate via Paypal
Re: Linked files with hard link
Is it possible to draw a conclusion in a non-modal window? Or tear it off right in your notepad.exe.
When "text $output" is displayed, the explorer is not available.
When "text $output" is displayed, the explorer is not available.
Re: Linked files with hard link
Then use something like
instead of
Code: Select all
writefile("%TEMP%\~fsutil.txt", $output, , "utf8");
run """notepad.exe"" ""%TEMP%\~fsutil.txt""";
Code: Select all
text $output;
One of my scripts helped you out? Please donate via Paypal
Re: Linked files with hard link
Last moment. If nothing is selected (click on an empty space), then the window is displayed. Can I fix this, if not difficult?
Re: Linked files with hard link
Code: Select all
if (!<get CountSelected>) { end true; }
One of my scripts helped you out? Please donate via Paypal
Re: Linked files with hard link
highend, Found a problem with symbols.
Re: Linked files with hard link
Try to replace
with
Code: Select all
$results = runret("""fsutil"" hardlink list ""<curitem>""", , 65001);
Code: Select all
$cmd = <<<>>>
cmd /c @chcp 65001 >NUL 2>NUL & fsutil hardlink list "<curitem>"
>>>;
$results = runret("$cmd", , 65001);
One of my scripts helped you out? Please donate via Paypal
Re: Linked files with hard link
Can't get information from folder \Systems32\