Page 2 of 3

Re: File name / Folder name select

Posted: 21 Jan 2014 01:26
by CookieMonster
I've tried the EqualTo operation, the Like operation and a few more, none of them work.

Code: Select all

foreach($folder, listpane( ,"*", 6)) {
        if ("<filename>" == $folder) {
            selectitems $folder, , 0, "a";
        }
    }

Code: Select all

foreach($folder, listpane( ,"*", 6)) {
        if ("<filename>" && $folder) {
            selectitems $folder, , 0, "a";
        }
    }

Code: Select all

foreach($folder, listpane( ,"*", 6)) {
        if ("<filename>" Like $folder) {
            selectitems $folder, , 0, "a";
        }
    }

Re: File name / Folder name select

Posted: 21 Jan 2014 02:09
by TheQwerty
Without knowing enough about what you're trying to match....

Code: Select all

$folder Like "<curbase>*"
Unfortunately, a.txt will select a, a-files, alpha, and alpha-files.
If it were always ending with -files then you could use <curbase>-files instead, and even make it == instead of like.
If instead the files part can differ but the - is always a separator (and not possibly part of <curbase>) you can use <curbase>-* with the like.

Failing those there is no select-items-which-are-the-same-but-not command which will magically read your mind - you'll have to write your own code to determine the similarity between two strings.

Re: File name / Folder name select

Posted: 21 Jan 2014 03:25
by CookieMonster
TheQwerty wrote:Without knowing enough about what you're trying to match....

Code: Select all

$folder Like "<curbase>*"
Unfortunately, a.txt will select a, a-files, alpha, and alpha-files.
If it were always ending with -files then you could use <curbase>-files instead, and even make it == instead of like.
If instead the files part can differ but the - is always a separator (and not possibly part of <curbase>) you can use <curbase>-* with the like.

Failing those there is no select-items-which-are-the-same-but-not command which will magically read your mind - you'll have to write your own code to determine the similarity between two strings.
The folders always end with the suffix in the folder name "-files" including the dash. In other words [filenameA1-files] curbase could select the matching folder to the file, not all matching folders as it was doing ?

Re: File name / Folder name select

Posted: 21 Jan 2014 03:31
by TheQwerty
CookieMonster wrote:The folders always end with the suffix in the folder name "-files" including the dash. In other words [filenameA1-files] curbase could select the matching folder to the file, not all matching folders as it was doing ?
Then you have your answer.. case closed!

Re: File name / Folder name select

Posted: 21 Jan 2014 05:41
by CookieMonster
I created a User-Defined Command, I also read on <curbase> within XYplorer Native Variables, doesn't seem difficult, but where do I place it ?

Re: File name / Folder name select

Posted: 22 Jan 2014 17:45
by CookieMonster
I don't understand how to use <curbase> could someone please help ?

Re: File name / Folder name select

Posted: 22 Jan 2014 18:03
by TheQwerty
<curbase> is just a variable which is replaced with the base name, portion of the name before any extension, of the currently selected and focused item.

Re: File name / Folder name select

Posted: 22 Jan 2014 18:26
by CookieMonster

Code: Select all

foreach($folder, listpane( ,"*", 6)) {
        if ("RoboSheep" == <curbase>-files) {
            selectitems $folder, , 0, "a";
        }
    }
Not the correct use of the syntax !

Re: File name / Folder name select

Posted: 22 Jan 2014 18:39
by highend
Will RoboSheep EVER match anything that has any kind of name concatenated with "-files"...
Probably...

Btw, you can count up to 1? That's the exact amount of files that will be compared (TheQwerty was already clear enough on that subject)...

Re: File name / Folder name select

Posted: 22 Jan 2014 18:45
by TheQwerty
CookieMonster wrote:

Code: Select all

foreach($folder, listpane( ,"*", 6)) {
        if ("RoboSheep" == <curbase>-files) {
            selectitems $folder, , 0, "a";
        }
    }
Not the correct use of the syntax !
Your are correct in that this is not correct.

Re: File name / Folder name select

Posted: 22 Jan 2014 18:46
by CookieMonster
TheQwerty wrote:
CookieMonster wrote:

Code: Select all

foreach($folder, listpane( ,"*", 6)) {
        if ("RoboSheep" == <curbase>-files) {
            selectitems $folder, , 0, "a";
        }
    }
Not the correct use of the syntax !
Your are correct in that this is not correct.
Great, what is the correct way to use the syntax ?

Re: File name / Folder name select

Posted: 22 Jan 2014 18:55
by TheQwerty
CookieMonster wrote:
TheQwerty wrote:
CookieMonster wrote:

Code: Select all

foreach($folder, listpane( ,"*", 6)) {
        if ("RoboSheep" == <curbase>-files) {
            selectitems $folder, , 0, "a";
        }
    }
Not the correct use of the syntax !
Your are correct in that this is not correct.
Great, what is the correct way to use the syntax ?
Depends on what you're trying to do... Try stepping through it to see where you've gone wrong.

Re: File name / Folder name select

Posted: 23 Jan 2014 04:08
by CookieMonster
If <curbase> is a variable, all within a few minutes I've tried a few things to the condition, everything I've tried doesn't work. Declaring <curbase> as a variable doesn't seem right !

Re: File name / Folder name select

Posted: 23 Jan 2014 07:49
by Stefan
Try this.

Step by Step to understand.

Select your file, then execute this script:
1)

Code: Select all

$base = "<curbase>";
    msg $base;


Next step.
Select your file, then execute this script:
2)

Code: Select all

$base = "<curbase>";
   msg $base;
   $folder = "$base-files";
   msg $folder;



Now the full script.
Select your file, then execute this script:
3)

Code: Select all

  if(exists("<curitem>") == 1){
     $base = "<curbase>";
     $folder = "$base-files";
     selectitems $folder;
  }else{msg "this is not a file";}

Or shorter.
Select your file, then execute this script:

Code: Select all

  if(exists("<curitem>") == 1){
     selectitems "<curbase>-files";
  }else{msg "this is not a file";}

Or, if you are sure to always select a file first:

Select your file, then execute this script:

Code: Select all

     selectitems "<curbase>-files";

See the help for more parameters.

HTH? :D

Re: File name / Folder name select

Posted: 24 Jan 2014 16:11
by CookieMonster
Stefan - Thanks that helped me make sense of the scripting in XYplorer, and now I know partially what you did by defining variables etc.

Code: Select all

if(exists("<curitem>") == 1){
     $base = "<curbase>";
     $folder = "$base-files";
     selectitems $folder + $base;
  }else{msg "this is not a file";}
The script doesn't select simultaneously select the folder when I select a file and run the script, I tried adding the two variables together in hopes that when I select the files then run the script, it would select the matching folders.