How to list folders which contains only, say, 5, items?
Thanks in advance.
Find # of Items in folders
-
highend
- Posts: 14993
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Find # of Items in folders
No time to make this more efficient atm...
Code: Select all
$limitFiles = 5;
$result = "";
foreach($folder, quicksearch("* /d", "<curpath>", "|")) {
$files = quicksearch("* /f", $folder);
if (gettoken($files, "count", "<crlf>") == $limitFiles) {
$result = $result . $folder . "<crlf>";
}
}
if ($result) {
text "Folder(s) with more than " . $limitFiles . " file(s):<crlf 2>". $result;
} else {
status "No appropriate folders found...", "8B4513", "stop";
}One of my scripts helped you out? Please donate via Paypal
-
armsys
- Posts: 557
- Joined: 10 Mar 2012 12:40
- Location: Hong Kong
Re: Find # of Items in folders
Hi highend,
Thanks a million for your quick script.
Thanks a million for your quick script.
-
armsys
- Posts: 557
- Joined: 10 Mar 2012 12:40
- Location: Hong Kong
Re: Find # of Items in folders
Highend's script refuses to work with an error msg:
The current script appears to be recursive.
The stack size is 0.
Is there a simple way to find all folders containing only 5 files thru the Find File tab (F12)?
The current script appears to be recursive.
The stack size is 0.
Is there a simple way to find all folders containing only 5 files thru the Find File tab (F12)?
-
highend
- Posts: 14993
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Find # of Items in folders
I let that script run on 6709 folders, 37092 files, 85,2 GB of data and didn't get a recursion warning...
Anyway, try this.
Anyway, try this.
Code: Select all
$limitFiles = 5;
setting "AllowRecursion", 1;
$folders = quicksearch("* /d", "<curpath>", "|");
$result = "";
foreach($folder, $folders) {
$files = quicksearch("* /f", $folder);
if (gettoken($files, "count", "<crlf>") == $limitFiles) {
$result = $result . $folder . "<crlf>";
}
}
if ($result) {
text "Folder(s) with more than " . $limitFiles . " file(s):<crlf 2>". $result;
} else {
status "No appropriate folders found...", "8B4513", "stop";
}One of my scripts helped you out? Please donate via Paypal
XYplorer Beta Club