Automatic retrieval of tags from the filename

Discuss and share scripts and script files...
atisoro
Posts: 29
Joined: 27 Jan 2025 16:27

Re: Automatic retrieval of tags from the filename

Post by atisoro »

this
Attachments
Captură de ecran 2025-01-30 212355.png
Captură de ecran 2025-01-30 212355.png (7.62 KiB) Viewed 4115 times

highend
Posts: 14571
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Automatic retrieval of tags from the filename

Post by highend »

Then remove this stuff before you further process it? replace() / regexreplace()...
One of my scripts helped you out? Please donate via Paypal

atisoro
Posts: 29
Joined: 27 Jan 2025 16:27

Re: Automatic retrieval of tags from the filename

Post 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

atisoro
Posts: 29
Joined: 27 Jan 2025 16:27

Re: Automatic retrieval of tags from the filename

Post 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" }¶	    }		"

highend
Posts: 14571
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Automatic retrieval of tags from the filename

Post 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>"")
One of my scripts helped you out? Please donate via Paypal

atisoro
Posts: 29
Joined: 27 Jan 2025 16:27

Re: Automatic retrieval of tags from the filename

Post 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" }
    }

klownboy
Posts: 4397
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: Automatic retrieval of tags from the filename

Post 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:

atisoro
Posts: 29
Joined: 27 Jan 2025 16:27

Re: Automatic retrieval of tags from the filename

Post by atisoro »

:tup:

Post Reply