Page 1 of 1

Is there a way to select all folders containing exactly 1 item?

Posted: 23 Dec 2024 19:17
by tonifelfe
Is there a way to select all folders containing exactly 1 item?

Re: Is there a way to select all folders containing exactly 1 item?

Posted: 23 Dec 2024 20:22
by WirlyWirly
I recently had to do something similar, here's the snippet I used but slightly modified for what you're doing. It'll select all the folders in your current list-view that only have 1 item inside.

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;


Re: Is there a way to select all folders containing exactly 1 item?

Posted: 24 Dec 2024 19:12
by tonifelfe
Thanks, great! Merry Christmas to everybody!