Page 1 of 2
Number of files in a folder
Posted: 22 Jul 2021 07:57
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 ?
Re: Number of files in a folder
Posted: 22 Jul 2021 08:31
by highend
Use a custom column with a script?
Code: Select all
$hardlinks = property("#hardlinks", <cc_item>);
if ($hardlinks > 1) { return $hardlinks; }
return "";
Re: Number of files in a folder
Posted: 22 Jul 2021 08:38
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.
Re: Number of files in a folder
Posted: 22 Jul 2021 09:43
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.
Re: Number of files in a folder
Posted: 22 Jul 2021 10:25
by zakoul
The script should count how many hardlinked files are in each folder.
Re: Number of files in a folder
Posted: 22 Jul 2021 10:33
by highend
The script should count how many hardlinked files are in each folder
Recursively?
Re: Number of files in a folder
Posted: 22 Jul 2021 10:54
by zakoul
I do not know
Re: Number of files in a folder
Posted: 22 Jul 2021 10:59
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)...
Re: Number of files in a folder
Posted: 22 Jul 2021 11:16
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).
Re: Number of files in a folder
Posted: 22 Jul 2021 11:21
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>) : "");
Re: Number of files in a folder
Posted: 22 Jul 2021 11:29
by zakoul
Thanks. Exactly what is needed.
Re: Number of files in a folder
Posted: 22 Jul 2021 14:41
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?
Re: Number of files in a folder
Posted: 22 Jul 2021 14:44
by highend
2nd post and then combine that stuff...
Re: Number of files in a folder
Posted: 24 Jul 2021 11:05
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>) : "");

And how can you change the color where 100% hits?
So that the color of the text in such cases is displayed in red.
Re: Number of files in a folder
Posted: 24 Jul 2021 11:43
by highend
Custom column text doesn't support colorization, maybe assign a label...