Page 2 of 2

Re: Automatic retrieval of tags from the filename

Posted: 30 Jan 2025 20:21
by atisoro
this

Re: Automatic retrieval of tags from the filename

Posted: 30 Jan 2025 20:45
by highend
Then remove this stuff before you further process it? replace() / regexreplace()...

Re: Automatic retrieval of tags from the filename

Posted: 31 Jan 2025 08:06
by atisoro
highend wrote: 30 Jan 2025 20:45 Then remove this stuff before you further process it? replace() / regexreplace()...

Code: Select all

 $allScripts = report("{basename} - ({comment})|",$allScripts);
 $allScripts = replace($allScripts," - ()");
so simple... :party:
thank you for your suggestion

Re: Automatic retrieval of tags from the filename

Posted: 31 Jan 2025 08:30
by atisoro
a script loader launcher (scan all scripts from XYscripts folder, preselect first script)
in my opinion is usefull and quick
I recommend adding a description of the script in the Comments column.

Add a User Button from Customize toolbar - Edit... - On left click action

Code: Select all

    $allScripts = listfolder(<xyscripts>, "*.xys");  
    $count_xys = gettoken($allScripts, "count", ",");

    if ($count_xys) {
    $allScripts = report("{basename} - ({comment})|",$allScripts);
    $allScripts = replace($allScripts," - ());
    $selectedscript = inputselect("Select one script to execute",$allScripts,,32);
        If ($selectedscript>"") 
           {
        $selectedscript = regexreplace($selectedscript, "(.+) -.+", "$1");
        load $selectedscript; 
           }
        } else {
    $mycom = "This is a autocreated script";
    writefile("<xyscripts>\hello.xys", " msg ""Your scripts folder not contain any script (*.xys)!<br>Warning:$mycom!<br>Script location is <xyscripts>"",48,,""$mycom"";");
    tag $mycom, "<xyscripts>\hello.xys", 2;
    load "<xyscripts>\hello.xys" }
    }
ar add code to XYplorer.ini

Code: Select all

[CustomButtons]
Version=1
Count=1
1=""script launcher|:ladybug|0|0" $allScripts = listfolder(<xyscripts>, "*.xys");  ¶	    $count_xys = gettoken($allScripts, "count", ",");¶	¶	    if ($count_xys) {¶	    $allScripts = replace(report("{basename} - ({comment})|",$allScripts)," - ()");¶	    $selectedscript = inputselect("Select one script to execute",$allScripts,,32);¶	        If ($selectedscript>"") ¶	           {¶	        $selectedscript = regexreplace($selectedscript, "(.+) -.+", "$1");¶	        load $selectedscript; ¶	           }¶	        } else {¶	    $mycom = "This is a autocreated script";¶	    writefile("<xyscripts>\hello.xys", " msg ""Your scripts folder not contain any script (*.xys)!<br>Warning:$mycom!<br>Script location is <xyscripts>"",48,,""$mycom"";");¶	    tag $mycom, "<xyscripts>\hello.xys", 2;¶	    load "<xyscripts>\hello.xys" }¶	    }		"

Re: Automatic retrieval of tags from the filename

Posted: 31 Jan 2025 08:44
by highend
$count_xys = gettoken($allScripts, "count", ",");?
listfolder() returns (by default) "|"-separated items so that count will always be one as long as at least one script exists

So:

Code: Select all

if ($allScripts) {
...
Missing the closing double quote:
$allScripts = replace($allScripts," - ());

A mathematical comparison for a string? oO
If ($selectedscript>"")

Re: Automatic retrieval of tags from the filename

Posted: 31 Jan 2025 09:08
by atisoro
I corrected the errors after posting.
mistakes happen...

Code: Select all

 $allScripts = listfolder(<xyscripts>, "*.xys");  
 end (!<get SelectedItemsPathNames>), "No item(s) selected, aborted!";
 if ($allScripts) {
    $allScripts = replace(report("{basename} - ({comment})|",$allScripts)," - ()");
    $selectedscript = inputselect("Select one script to execute",$allScripts,,32);
        If ($selectedscript) {
        $selectedscript = regexreplace($selectedscript, "(.+) -.+", "$1");
        load $selectedscript; 
           }
        } else {
    $mycom = "This is a autocreated script";
    writefile("<xyscripts>\hello.xys", " msg ""Your scripts folder not contain any script (*.xys)!<br>Warning:$mycom!<br>Script location is <xyscripts>"",48,,""$mycom"";");
    tag $mycom, "<xyscripts>\hello.xys", 2;
    load "<xyscripts>\hello.xys" }
    }

Re: Automatic retrieval of tags from the filename

Posted: 31 Jan 2025 15:52
by klownboy
I'd have fun with this script. I have 1066 scripts in my XYplorer script folder. :) :eh: Maybe it's time to weed through it. :whistle:

Re: Automatic retrieval of tags from the filename

Posted: 31 Jan 2025 17:03
by atisoro
:tup: