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

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
tonifelfe
Posts: 46
Joined: 17 Jun 2009 14:03
Location: Win10 Pro, 64-bit, Version 22H2, Screen DPI: 120 (125%)

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

Post by tonifelfe »

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

WirlyWirly
Posts: 263
Joined: 21 Oct 2020 23:33
Location: Win 10 @ 100% (3440x1440)

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

Post 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;


tonifelfe
Posts: 46
Joined: 17 Jun 2009 14:03
Location: Win10 Pro, 64-bit, Version 22H2, Screen DPI: 120 (125%)

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

Post by tonifelfe »

Thanks, great! Merry Christmas to everybody!

Post Reply