Page 1 of 1

Auto-select certain file when entering folder

Posted: 20 Jun 2021 03:21
by greentea
Hi All,

I'm new to XYplorer and really like it so far :appl: I came across this script in Directory Opus for automatically selecting a file when navigating to a folder:
https://resource.dopus.com/t/auto-selec ... ders/20413

I'm not experienced with scripting - can anyone describe how this script can be adapted to work in XYplorer?

Re: Auto-select certain file when entering folder

Posted: 20 Jun 2021 07:41
by highend
Configuration | General | Custom Event Actions
Even: Changing Locations - After painting the file list
Action: Run script
Script:

Code: Select all

    $list = <<<>>>
*\Directory Opus::dopus.exe
*\Outlook::Outlook.pst
C:\Passwords::File4.txt|File2.txt|another file.txt
    >>>;

    // "[" and "#" need to be surrounded by "[]" for a "LikeI" comparison
    foreach($item, $list, <crlf>, "e") {
        if (<newpath> LikeI regexreplace(gettoken($item, 1, "::", "t"), "([#\[])", "[$1]")) {
            selectitems gettoken($item, 2, "::", "t");
            break;
        }
    }
To select multiple files, just append them on the right side of a line, separated with "|". Like it is done in:
C:\Passwords::File4.txt|File2.txt|another file.txt

Re: Auto-select certain file when entering folder

Posted: 22 Jun 2021 20:37
by greentea
Thanks for the code, greatly appreciate it!