How to set folder and subfolders in Details mode while contents in Icon mode

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Mosed
Posts: 12
Joined: 13 Jan 2022 19:33

Re: How to set folder and subfolders in Details mode while contents in Icon mode

Post by Mosed »

ok. A help area for "quick search" and another for "quicksearch()".

Thank you.

With a reference in this forum I managed to add the /n switch:

Code: Select all

    $files     = listfolder(<newpath>, , 1, <crlf>);
    $cntFiles  = gettoken($files, "count", <crlf>);
    $images    = quicksearch("{:Image} /n", $files);
    $cntImages = gettoken($images, "count", <crlf>);
    if ($cntFiles) {
        $percent = $cntImages / $cntFiles;

        if ($percent >= 0.75) {
            if (get("view") != 9) { #314; } // Large Tiles view
        } else {
            if (get("view") != 0) { #302; } // Details view
        }
    }
But the switch back to "details" does only work if there are files in the current folder. If there are only folders the view stays at "large tiles".
I guess the problem is that the script counts only images and files and not folders. And if there are no images and no files it does nothing.
So I would have to change the script that it counts also folders - Or that it changes back to details if there are only folders. Right?


EDIT:

Code: Select all

    $files     = listfolder(<newpath>, , 1, <crlf>);
    $cntFiles  = gettoken($files, "count", <crlf>);
    $images    = quicksearch("{:Image} /n", $files);
    $cntImages = gettoken($images, "count", <crlf>);
    if ($cntFiles) {
        $percent = $cntImages / $cntFiles;

        if ($percent >= 0.75) {
            if (get("view") != 9) { #314; } // Large Tiles view
        } else {
            if (get("view") != 0) { #302; } // Details view
        }
    }
    else {
            if (get("view") != 0) { #302; } // Details view
    }
Seems to work.
But I still get an error message regarding the bluray device when I open "this computer", because this search area is not available. beside I do not open it. I thought subfolders are ignored now?

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: How to set folder and subfolders in Details mode while contents in Icon mode

Post by highend »

Or

Code: Select all

    $files     = listfolder(<newpath>, , 1, <crlf>);
    $cntFiles  = gettoken($files, "count", <crlf>);
    $images    = quicksearch("{:Image} /n", $files);
    $cntImages = gettoken($images, "count", <crlf>);
    if ($cntFiles && $cntImages) {
        if ($cntImages / $cntFiles >= 0.75) {
            if (get("view") != 9) { #314; }
            end true;
        }
    }
    if (get("view") != 0) { #302; }
My code was just an example. It's up to the user under which circumstances a view mode is set / reset
But I still get an error message regarding the bluray device when I open "this computer", because this search area is not available. beside I do not open it. I thought subfolders are ignored now?
And the error message is?

If in doubt, exclude such places, e.g. with:

Code: Select all

    $exclusions = "This PC|This Computer";
    if (strpos($exclusions, <newpath>) != -1) { end true; }
at the beginning
One of my scripts helped you out? Please donate via Paypal

Mosed
Posts: 12
Joined: 13 Jan 2022 19:33

Re: How to set folder and subfolders in Details mode while contents in Icon mode

Post by Mosed »

highend wrote: 15 Jan 2022 18:16 And the error message is?
Error.PNG
Error.PNG (6.83 KiB) Viewed 398 times
So it seems the script tries to search inside G: (That is the bluray drive).
If in doubt, exclude such places, e.g. with:

Code: Select all

    $exclusions = "This PC|This Computer";
    if (strpos($exclusions, <newpath>) != -1) { end true; }
at the beginning
ok. that helps. Thank you.
Hint for german language users: Replace "This" with "Dieser".

Post Reply