Page 1 of 1

<scriptpath> Variable in XYScripts

Posted: 07 Nov 2026 06:09
by WirlyWirly
It would be handy to have a <scriptpath> variable that can be used in .xys files.

We can get the path of the current script using self('path'), but this feels like something there should be a native variable for.

In my case, I have a .ini configuration file that might contain <variable> placeholders, so I'm using eval() to resolve these strings into their actual values...

Code: Select all

[ProgramPaths]
jq=<scriptpath>\resources\programs\jq\jq.exe
mediaInfoCLI=<xyparent>\Command\programs\mediainfo\MediaInfo.exe
movieThumbnailer=<xyparent>\MovieThumbnailer\mtn.exe

Code: Select all

if ( $variable LikeI '<scriptpath>' ) {
    // This variable should be replaced with the path of the current script
    $value= replace($value, "$variable", self('path'));

} else {
    // This is a native XY variable and should be resolved
    $value= replace($value, "$variable", eval("$variable"));

}
It's not a big deal to have a small block for my custom variable, but while writing it I noticed the lack of such a functional variable and thought that it would be a simple but useful feature, maybe along with <scriptname>. Both these variables are very handy for constructing relative paths when writing portable XYScripts.

Re: <scriptpath> Variable in XYScripts

Posted: 09 Nov 2026 12:13
by admin
Exists already: <xyscripts> :)

Re: <scriptpath> Variable in XYScripts

Posted: 09 Nov 2026 12:49
by WirlyWirly
Kind of, but that variable is for the XY scripts directory, so if your script is outside that folder, nested 1 level deep, or just has its folder renamed, then that variable is no longer reliable.

Variables like <scriptpath> and <scriptname> would never fail, since they would be based on the absolute path of the script itself at runtime, not the path of the XY scripts folder.

Re: <scriptpath> Variable in XYScripts

Posted: 09 Nov 2026 13:00
by admin
Ah, I see. I think self('path') is perfect for this.