Using selectitems $matches multiple file selection does not work

Things you’d like to miss in the future...
Forum rules
:warnred20: :warnred20: :warnred20: :warnred20: :warnred20: READ THIS AND DO IT!!! :warnred20: :warnred20: :warnred20: :warnred20: :warnred20:

:info: Please include the following information:
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).

:info: We recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once.

:info: When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".

:warnred20: :warnred20: :warnred20: :warnred20: :warnred20: READ THIS AND DO IT!!! :warnred20: :warnred20: :warnred20: :warnred20: :warnred20:
Post Reply
star
Posts: 46
Joined: 11 Mar 2022 08:18

Using selectitems $matches multiple file selection does not work

Post by star »

`$matches` contains full paths separated by the `|` symbol, but when I run the script, nothing happens. Only after pressing F2 to enter rename mode and then exiting, running the script can select files. Why is this happening? I asked AI, and it said XYPlorer’s directory caching mechanism might be causing the problem, suggesting adding `#500; wait 100;` might help, but I tried it and it didn’t work.

$matches=I:\BaiduNetdiskDownload\待净化\soul-ibm5100-6810-20250504\6810-[ほおぶくろっ! (ベコ太郎)] part1\1. 同人志\VariouSketch 2(C86)|I:\BaiduNetdiskDownload\待净化\soul-ibm5100-6810-20250504\6810-[ほおぶくろっ! (ベコ太郎)] part1\1. 同人志\生イキ狂イ ~生意気娘をわからせ快楽狂いに~(C101)|I:\BaiduNetdiskDownload\待净化\soul-ibm5100-6810-20250504\6810-[ほおぶくろっ! (ベコ太郎)] part1\1. 同人志\私のいちばん恥ずかしいところ。(COMIC1☆11)

3 files:
VariouSketch 2(C86)
生イキ狂イ ~生意気娘をわからせ快楽狂いに~(C101)
私のいちばん恥ずかしいところ。(COMIC1☆11)

How can I make `selectitems $matches;` work successfully to select multiple files? Operation details are shown in the image below.

https://i.imgur.com/iuUp4Bv.gif
Image

Code: Select all

// XYplorer Script: Select Similar (robust encoding)
  $python = "C:\ProgramData\anaconda3\envs\python312\python.exe";
  $pyscript = "C:\Users\Administrator\Personal_scripts\Python\PythonScripts\PythonScripts\src\select_similar.py";
  $tempfile = "%temp%\filelist.txt";

  // --- 1. write file(utf-16-le) ---
  $items = folderreport("dirs", "r", "<curpath>", "<crlf>");
  writefile($tempfile, $items);
  //msg $items;

  // --- 2. Python output---
  $cmd = """$python"" ""$pyscript"" ""$tempfile"" 2>&1";
  $output = runret($cmd);

  // --- 3. Python Error ---
  if (strpos($output, "Traceback") != -1 || strpos($output, "Error") != -1 || strpos($output, "Exception") != -1) {
    msg "⚠️ Python Error:<crlf><crlf>$output";
    end 1;
  }

  // --- 4. Python output(UTF-16-LE) ---
  if (exists($tempfile)) {
    $matches = readfile($tempfile, "utf16-le"); // Python 写回时固定 UTF-16-LE
    // msg $matches;
    if ($matches != "") {
      selectitems $matches;
      msg $matches;
    } else {
      msg "No matches";
    }
  } else {
    msg "❌ Not find file:$tempfile";
  }
XYPlorer x32 Ver 27.10.0600, Win10 LSTC Enterprise 21H2, scaling percentage 200%(Display 4K)

admin
Site Admin
Posts: 65064
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Using selectitems $matches multiple file selection does not work

Post by admin »

Are these three items files or folders? If they are folders, do they have a trailing slash? If so, the problem is explained: it is a bug. It will be fixed in the next beta version.

star
Posts: 46
Joined: 11 Mar 2022 08:18

Re: Using selectitems $matches multiple file selection does not work

Post by star »

admin wrote: 28 Oct 2025 12:57 Are these three items files or folders? If they are folders, do they have a trailing slash? If so, the problem is explained: it is a bug. It will be fixed in the next beta version.

If you can see the GIF, it's obvious that they are folders. The small icons on the left of these three folders display the folder icon.


According to the screenshot, the path returned by Python does not end with a backslash (\). I have already shown the msg $matches above.


msg $matches show:

Code: Select all

I:\BaiduNetdiskDownload\待净化\soul-ibm5100-6810-20250504\6810-[ほおぶくろっ! (ベコ太郎)] part1\1. 同人志\VariouSketch 2(C86)|I:\BaiduNetdiskDownload\待净化\soul-ibm5100-6810-20250504\6810-[ほおぶくろっ! (ベコ太郎)] part1\1. 同人志\生イキ狂イ ~生意気娘をわからせ快楽狂いに~(C101)|I:\BaiduNetdiskDownload\待净化\soul-ibm5100-6810-20250504\6810-[ほおぶくろっ! (ベコ太郎)] part1\1. 同人志\私のいちばん恥ずかしいところ。(COMIC1☆11)
I:\BaiduNetdiskDownload\待净化\soul-ibm5100-6810-20250504\6810-[ほおぶくろっ! (ベコ太郎)] part1\1. 同人志\VariouSketch 2(C86)
I:\BaiduNetdiskDownload\待净化\soul-ibm5100-6810-20250504\6810-[ほおぶくろっ! (ベコ太郎)] part1\1. 同人志\生イキ狂イ ~生意気娘をわからせ快楽狂いに~(C101)
I:\BaiduNetdiskDownload\待净化\soul-ibm5100-6810-20250504\6810-[ほおぶくろっ! (ベコ太郎)] part1\1. 同人志\私のいちばん恥ずかしいところ。(COMIC1☆11)


Additionally, if I use Python to rename a bunch of folders and then perform a selection operation, sometimes the folders that were renamed by the script are not selected by XYPlorer.
XYPlorer x32 Ver 27.10.0600, Win10 LSTC Enterprise 21H2, scaling percentage 200%(Display 4K)

admin
Site Admin
Posts: 65064
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Using selectitems $matches multiple file selection does not work

Post by admin »

Sorry, can't explain your issues. It works fine here. :|

Post Reply