There are only two variables to modify:
$percent = The value for how many files (as a percentage of all files) at which a folder view get's activated
$types = The lines that define the view mode and the extensions that have to match
The view mode is separated from the extensions via a bar character "|" and the extensions are delimited via a semicolon.
You can use the XY internal general file types here!
These currently are:
{:Text};{:Image};{:Photo};{:Audio};{:Video};{:Media};{:Font};{:Vector};{:Web};{:Office};{:Archive};{:Executable}
Put this script in a user defined command and execute it e.g. from a user defined button or a keyboard shortcut...
Code: Select all
// === CONFIGURE VARIABLES #BEGIN ===
$percent = 26;
$types = <<<>>>
// View command | Extensions
#302|*.doc;*.txt;{:Office}
#306|*.jpg;*.png;*.tiff
>>>;
// === CONFIGURE VARIABLES #END =====
/*
{#View} | Command
=========================================
0 = Details | #302
1 = Details with Thumbnails #1 | #303
2 = List | #304
3 = Small Icons | #305
4 = Thumbnails #1 | #306
5 = Thumbnails #2 | #307
6 = Thumbnails #3 | #308
7 = Large Icons | #309
8 = Small Tiles | #313
9 = Large Tiles | #314
Generic file type "variables"
=============================
{:Text}
{:Image}
{:Photo}
{:Audio}
{:Video}
{:Media}
{:Font}
{:Vector}
{:Web}
{:Office}
{:Archive}
{:Executable}
*/
$files = listpane(, , 1+4);
$filesCount = gettoken($files, "count", "|");
$types = regexreplace($types, "^//.*\r?\n");
$curView = get("View");
if !($filesCount) { status "No file(s) in current directory, no view change necessary!", "8B4513", "stop"; end 1==1; }
$command = "";
foreach($entry, $types, "<crlf>", "e") {
$extensions = gettoken($entry, 2, "|");
if (strpos($extensions, "{") != -1) {
$resolvedExtensions = "";
foreach($ext, $extensions, ";", "e") {
if (regexmatches($ext, "\{:[a-z0-9]+}")) { $resolved = get("genericfiletype", $ext, ";"); }
else { $resolved = $ext; }
$resolvedExtensions = $resolvedExtensions . $resolved . ";";
}
$extensions = $resolvedExtensions;
}
$extensions = formatlist($extensions, "sde", ";");
$typeCount = gettoken(formatlist($files, "f", , replace($extensions, ";", "|"), "f"), "count", "|");
if (($typeCount / ($filesCount / 100)) < $percent) { continue; }
$command = gettoken($entry, 1, "|");
break;
}
if ($command) {
if ($command == "#302" && $curView == 0 ||
$command == "#303" && $curView == 1 ||
$command == "#304" && $curView == 2 ||
$command == "#305" && $curView == 3 ||
$command == "#306" && $curView == 4 ||
$command == "#307" && $curView == 5 ||
$command == "#308" && $curView == 6 ||
$command == "#309" && $curView == 7 ||
$command == "#313" && $curView == 8 ||
$command == "#314" && $curView == 9) {
status "No view change necessary!", "8B4513", "stop"; end 1==1;
}
load "$command", , "s";
}
XYplorer Beta Club