Is there a way to select all folders containing exactly 1 item?
Posted: 23 Dec 2024 19:17
Is there a way to select all folders containing exactly 1 item?
Forum for XYplorer Users and Developers
https://www.xyplorer.com/xyfc/
Code: Select all
$allFolders = quicksearch(">.* /d /maxdepth=0", <curpath>, "|");
$singleFileFolders = '';
foreach($folder, $allFolders, "|") {
$folderContents = quicksearch(">.* /maxdepth=0", $folder, "|");
$fileCount = gettoken($folderContents, "count", "|");
if ($fileCount == 1) {
$singleFileFolders = $singleFileFolders . $folder . "|";
}
}
selectitems $singleFileFolders;