<scriptpath> Variable in XYScripts

Features wanted...
Post Reply
WirlyWirly
Posts: 332
Joined: 21 Oct 2020 23:33
Location: XY 64-Bit | Win 11 @ 100% (3440x1440)

<scriptpath> Variable in XYScripts

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

admin
Site Admin
Posts: 67271
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: <scriptpath> Variable in XYScripts

Post by admin »

Exists already: <xyscripts> :)

WirlyWirly
Posts: 332
Joined: 21 Oct 2020 23:33
Location: XY 64-Bit | Win 11 @ 100% (3440x1440)

Re: <scriptpath> Variable in XYScripts

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

admin
Site Admin
Posts: 67271
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: <scriptpath> Variable in XYScripts

Post by admin »

Ah, I see. I think self('path') is perfect for this.

Post Reply