Page 1 of 1

Pane 1 triggers Containing Folder in Pane 2

Posted: 18 Jan 2019 06:53
by loungebob
Can xyplorer display the folder in pane 2 containing the file in pane 1? Basically I need the folder and its content displayed in pane 2 for every file I click in pane 1. No scripts - unless it runs permanently and requires no user interaction, no right-click. It needs to work automatically.

I have a flat folder with hundreds of files that need to be sorted into an existing folder and subfolder structure. The subfolders contain files with the same file names as those in the flat folder but are of a different file type. If I put those all in a top level folder and use branch view and if the above would work I could rather quickly solve this task.

I assume one could write a batch file to accomplish this but I cant, too blond. Also, beyondcompare cant master this task either. So looks like I’m stuck finding an efficient file manager to help me do it.

Re: Pane 1 triggers Containing Folder in Pane 2

Posted: 18 Jan 2019 08:22
by highend
Possible with scripting but
01. XY can't change the path in the other pane without changing focus
So whenever a new file from a different folder would be selected in pane 1
a short flickering (focus pane 2, goto folder, focus pane 1) would occur
02. A press of Esc would terminate the running script

Re: Pane 1 triggers Containing Folder in Pane 2

Posted: 18 Jan 2019 15:26
by bdeshi
loungebob wrote: 18 Jan 2019 06:53 I need the folder and its content displayed in pane 2 for every file I click in pane 1.
You have to give a detailed explanation of the file -> folder relationship: how to figure out exactly which folder to show for which file? just search for the same base file name in subfolders? Are all filenames unique for sure?

Re: Pane 1 triggers Containing Folder in Pane 2

Posted: 19 Jan 2019 03:35
by loungebob
I tried your script viewtopic.php?t=17968 but I get an “outdated preview” error.
I cant believe this isn't part of the basic functions of xyplorer.

Basically there’s a Root Folder containing 2 Folders.
Folder 1 with a gazillion files, all file names unique and all the same file types.
Folder 2 with lots of Subfolders that contain Subfolders too. In those Subfolders, there’s always one file that matches the name of a File in Folder 1 but is not of the same File Type as the File in Folder 1. Names match though.

The Files in Folder 1 need to move to the corresponding Subfolder in Folder 2 containing the matching File Name.

Using the Branch View I visually achieve this. Now if there was a sync/merge function or a “load containing folder in other pane automatically” I could achieve this on a practical sphere too.

Re: Pane 1 triggers Containing Folder in Pane 2

Posted: 19 Jan 2019 08:34
by highend
I cant believe this isn't part of the basic functions of xyplorer
And this is a basic part of which file manager?
Now if there was a sync/merge function or a “load containing folder in other pane automatically”
And now it can be a totally different thing (not "fully" automatically) but just a simple: Move files from the current
dir into (to be found) destination folders?

Code: Select all

    $dstRoot = "<path to a folder that is the ROOT for all subfolders>";

    $rootFiles = listfolder(, , 1, <crlf>);
    $possibleMatches = quicksearch("/f", $dstRoot, , "s");
    if !($possibleMatches) { status "No possible destination folder(s) found, aborted!", "8B4513", "stop"; end true; }
    foreach($file, $rootFiles, <crlf>, "e") {
        $match = regexmatches($possibleMatches, "^.*\\" . regexreplace(gpc($file, "base"), "([\\.+(){\[^$])", "\$1") . "\.[^.]+?(?=\r?\n|$)");
        if ($match) { moveto gpc($match, "path"), $file, , 1, 2; }
    }
And ofc you MUST be in the folder that contains ALL source files (and that pane must be the active one...)

Re: Pane 1 triggers Containing Folder in Pane 2

Posted: 19 Jan 2019 10:38
by bdeshi
loungebob wrote: 19 Jan 2019 03:35 I tried your script viewtopic.php?t=17968 but I get an “outdated preview” error.
I cant believe this isn't part of the basic functions of xyplorer.
Of course you do, because that script is supposed to preview selected folders, not files nor arbitrarily related folders.
I cant believe this isn't part of the basic functions of xyplorer.
I guess because this is not a very common operation.

Now, what you want to do, I think is best handled with a scripted batch operation rather than a previewer like that FolderPanePreview script.

So try this script.
Instructions: Go to the "Root Folder", then run the script. It will ask you to choose folders: first, the source "Folder 1 with a gazillion files"; and second, the "Folder 2 with lots of Subfolders". Then the script will automatically match each file in source Folder 1 to subfolders of Folder 2 containing a file with the same base name, and finally move the files there (with a report).

Code: Select all

"filemover-166200"
 $src_root = inputfolder(<curpath>, "Source");
 $dst_root = inputfolder(<curpath>, "Destination");
 $src_names = listfolder($src_root,, 1+4);
 $moved_log = '';

 setting 'BackgroundFileOps', 0;
 foreach($src_name, $src_names) {
   $src_base = gpc($src_name, 'base');
   $src = $src_root . '\' . $src_name;
   $dst_match = quicksearch($src_base . '.* /rf', $dst_root, '|', 's');
   if $dst_match {
     if (gettoken($dst_match, 'count', '|') > 1) {
       $dst_match = inputselect('Multiple matches found. Choose target(s)',
                                $dst_match,, 1+2, "",,, "PICK TARGET");
       if !($dst_match) { 
         continue;
       }
     }
     foreach ($dst_file, $dst_match) {
       $dst = gpc($dst_file, 'path');
       copyto $dst, $src,,, 2, -1;
       $moved_log = $src . '  -->  ' . $dst . <crlf> . $moved_log;
     }
     delete 1, 0, $src;
   }
 }

 text $moved_log,,, "FILE DISTRIBUTION REPORT"; 
(well seeing as highend already posted a script, you can just use that. I'll keep my alternative take on the problem here anyway.)