How to modify the Views mode automatically?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
SIPHON
Posts: 2
Joined: 11 Nov 2022 18:31

How to modify the Views mode automatically?

Post by SIPHON »

Look at the default Windows File Explorer, when I enter a folder full of pictures or videos, it will switch to Thumbnails mode automatically, and when exit it will return to Details mode.

But in XYplorer, I have to manage the Folder View Settings by hand for every folder. Can this complete automatically like the default explorer? I have not seen such an item in settings.

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: How to modify the Views mode automatically?

Post by highend »

Sure, custom event actions allow to do something like this...

Configuration | General | Custom Event Actions

Changing Locations - After painting the file list

Run script

Code: Select all


    // At a rate of 75% image files, go into large icon view
    $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") != 7) { #308; } // Thumbnails #3
        } else {
            if (get("view") != 0) { #302; } // Details view
        }
    }
One of my scripts helped you out? Please donate via Paypal

SIPHON
Posts: 2
Joined: 11 Nov 2022 18:31

Re: How to modify the Views mode automatically?

Post by SIPHON »

Many thanks to you, it works!

Additionally I find several points about it
①If I set the script at "Before browsing a folder" instead of "After painting the file list", it seems to act more smoothly
②The value '7' in the judging condition should be '6' instead
③The script will cause some error when enter specific folders like the trashcan and My PC. Well, it's not a big problem, but I still wonder if I can do something to fix, or just ignore it.

Post Reply