Number of files in a folder

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
zakoul
Posts: 76
Joined: 11 Dec 2019 10:44

Number of files in a folder

Post by zakoul »

Is it possible to create a column that would display the number of files in a folder with a property prop:#HardLinks:>1 ?

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

Re: Number of files in a folder

Post by highend »

Use a custom column with a script?

Code: Select all

$hardlinks = property("#hardlinks", <cc_item>);
    if ($hardlinks > 1) { return $hardlinks; }
    return "";
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

zakoul
Posts: 76
Joined: 11 Dec 2019 10:44

Re: Number of files in a folder

Post by zakoul »

Yes. Does the script only work for files?
Can I do it for folders?
To display the number of files in the folder.

Horst
Posts: 297
Joined: 24 Jan 2021 12:27
Location: Germany

Re: Number of files in a folder

Post by Horst »

zakoul wrote: 22 Jul 2021 08:38 Yes. Does the script only work for files?
Can I do it for folders?
To display the number of files in the folder.
There is no such thing as a hard link to a directory in Windows.
Windows 10 Home x64 Version 21H2 (OS Build 19044.1110)
Portable XYplorer v22.10.0013
Everything 1.5.0.1270a (x64)

zakoul
Posts: 76
Joined: 11 Dec 2019 10:44

Re: Number of files in a folder

Post by zakoul »

The script should count how many hardlinked files are in each folder.

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

Re: Number of files in a folder

Post by highend »

The script should count how many hardlinked files are in each folder
Recursively?
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

zakoul
Posts: 76
Joined: 11 Dec 2019 10:44

Re: Number of files in a folder

Post by zakoul »

I do not know
Last edited by zakoul on 22 Jul 2021 11:02, edited 1 time in total.

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

Re: Number of files in a folder

Post by highend »

Code: Select all

    $files    = listfolder(<cc_item>, , 1, <crlf>);
    $cntFiles = 0;
    foreach($file, $files, <crlf>, "e") {
        if (property("#HardLinks", $file) > 1) { $cntFiles++; }
    }
    return $cntFiles;
But this is a bit misleading because it counts files that are the source of the hardlink as well (due to the nature of that property)...
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

zakoul
Posts: 76
Joined: 11 Dec 2019 10:44

Re: Number of files in a folder

Post by zakoul »

Thanks.
Is it possible to hide zero results and indicate the total number of files after "/"?
For example 13/65 (13-hardlink>1 / 65-all files in folder).

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

Re: Number of files in a folder

Post by highend »

That is no rocket science...

Code: Select all

    $files    = listfolder(<cc_item>, , 1, <crlf>);
    $cntFiles = 0;
    foreach($file, $files, <crlf>, "e") {
        if (property("#HardLinks", $file) > 1) { $cntFiles++; }
    }
    return ($cntFiles ? $cntFiles . "/" . gettoken($files, "count", <crlf>) : "");
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

zakoul
Posts: 76
Joined: 11 Dec 2019 10:44

Re: Number of files in a folder

Post by zakoul »

Thanks. Exactly what is needed.

zakoul
Posts: 76
Joined: 11 Dec 2019 10:44

Re: Number of files in a folder

Post by zakoul »

Can I add that the number of hard links is also displayed for the files in the same custom column?
highend wrote: 22 Jul 2021 10:33 Recursively?
How's that? Will the results be displayed faster?
Last edited by zakoul on 22 Jul 2021 14:44, edited 1 time in total.

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

Re: Number of files in a folder

Post by highend »

2nd post and then combine that stuff...
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

zakoul
Posts: 76
Joined: 11 Dec 2019 10:44

Re: Number of files in a folder

Post by zakoul »

Code: Select all

    $hardlinks = property("#hardlinks", <cc_item>);
    if ($hardlinks > 1) { return $hardlinks; }
    $files    = listfolder(<cc_item>, , 1, <crlf>);
    $cntFiles = 0;
    foreach($file, $files, <crlf>, "e") {
        if (property("#HardLinks", $file) > 1) { $cntFiles++; }
    }
    return ($cntFiles ? $cntFiles . "/" . gettoken($files, "count", <crlf>) : "");
Image
And how can you change the color where 100% hits?
So that the color of the text in such cases is displayed in red.

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

Re: Number of files in a folder

Post by highend »

Custom column text doesn't support colorization, maybe assign a label...
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

Post Reply