Edit: List All Script Files

Discuss and share scripts and script files...
jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Edit: List All Script Files

Post by jacky »

Well, since we have a new place to share scripts, I thought I'll share some scripts I've made recently...

This little script will popup a menu listing all your script files, allowing you to chose which one to edit. In order to work all your script files must be located under a subfolder "Scripts", or you'll have to change the location used ("<xypath>\Scripts"), and must be called *.xys, or you'll have to change the selection filter ("*.xys").

Code: Select all

"Edit: List All Script Files..."
 // Open New Tab
 #340;
 // goto folder
 goto "<xypath>\Scripts";
 sortby name, a;
 sel 1,0;
 selfilter "*.xys";
 // Copy Item Path/Name(s)
 #101;
 set $script, <clipboard>;
 // Close Tab
 #351;
 regexreplace $script, $script, "^(.+)\\(.+)\.xys$", """Edit $2"" open  ""$1\$2.xys"";";
 load $script,,s;
Also, they need to be associated with a text editor of your choice, since the command used here is open. Easiest way to do that is simply to add a PFA for *.xys to your text editor of choice.

And if you don't want to use any associations, you can also specifiy the app to start, with the script file as parameter, in the generated script (on the regexreplace command)

Here's an example of that, using notepad :

Code: Select all

 regexreplace $script, $script, "^(.+)\\(.+)\.xys$", """Edit $2"" open """"notepad"" $1\$2.xys"";";
Proud XYplorer Fanatic

RalphM
Posts: 2042
Joined: 27 Jan 2005 23:38
Location: Cairns, Australia

Post by RalphM »

Nice script Jacky, thanks.

Since we all somehow agreed, that the subfolder "Scripts" of appath should be the standard location for scriptfiles, wouldn't it make sense, if the Scripts / Load Script File... menu command would go there automatically? Or should a standard script path variable be added to the config?
Ralph :)
(OS: W11 24H2 Home x64 - XY: Current x32 beta - Office 2024 32-bit - Display: 1920x1080 @ 125%)

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

Post by admin »

RalphM wrote:Nice script Jacky, thanks.

Since we all somehow agreed, that the subfolder "Scripts" of appath should be the standard location for scriptfiles, wouldn't it make sense, if the Scripts / Load Script File... menu command would go there automatically? Or should a standard script path variable be added to the config?
I did that.
I just wonder if this order
<xydata>
<xydata>\Scripts
or this order
<xydata>\Scripts
<xydata>
is better.
Maybe the second, and thus making \Scripts the "official" first location for script files. Okay?

j_c_hallgren
XY Blog Master
Posts: 5826
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Post by j_c_hallgren »

admin wrote:Maybe the second, and thus making \Scripts the "official" first location for script files. Okay?
Fine with me! Sounds like a workable plan with little or no impact on current users.
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

Yep, fine with me. Means I'll be able to remove "Scripts\" from all my calls ;)

So, does that mean menu Scripting|Load Script File will try to open in that folder Scripts first, and only if it doesn't exist be in <xydata> ? Would make sense as well I'd say.

(And if you really want to make this a default folder, why not create it yourself when XY is starting for the very first time, along with FindTemplates & NewItems ? Just to "help" new users to use this folder...)
Proud XYplorer Fanatic

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

Post by admin »

jacky wrote:Yep, fine with me. Means I'll be able to remove "Scripts" from all my calls ;)

So, does that mean menu Scripting|Load Script File will try to open in that folder Scripts first, and only if it doesn't exist be in <xydata> ?
Exactly!
jacky wrote:(And if you really want to make this a default folder, why not create it yourself when XY is starting for the very first time, along with FindTemplates & NewItems ? Just to "help" new users to use this folder...)
Well, If they cannot even create a folder...

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

admin wrote:Well, If they cannot even create a folder...
I'm sure they can, but for newcomers that don't start by reading the entire help, to see a such a folder will have them use it. Otherwise, they might not know about it, and since Scripting|Load Script File would not open there obviously but in <xydata> they could easily assume that this is the default place...
Proud XYplorer Fanatic

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

Post by admin »

jacky wrote:
admin wrote:Well, If they cannot even create a folder...
I'm sure they can, but for newcomers that don't start by reading the entire help, to see a such a folder will have them use it. Otherwise, they might not know about it, and since Scripting|Load Script File would not open there obviously but in <xydata> they could easily assume that this is the default place...
Okay, but ensuring/creating a folder at startup takes time. Nothing is for free. :wink:

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

admin wrote:Okay, but ensuring/creating a folder at startup takes time. Nothing is for free. :wink:
Yeah but that's why I said only "the very first time", I assumed you had a way to tell already if it was or not (eg. cause there's no INI present).

Otherwise you're right, no big deal, leave it as is.
Proud XYplorer Fanatic

j_c_hallgren
XY Blog Master
Posts: 5826
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Post by j_c_hallgren »

Or...why not just create it via the Installation process, like most other apps do? And have it as empty folder within the no-install process so it would be established then also.
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

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

Post by admin »

j_c_hallgren wrote:Or...why not just create it via the Installation process, like most other apps do? And have it as empty folder within the no-install process so it would be established then also.
Because I have a no-install package, too. And because I don't like it.

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

Post by admin »

Well, I did it anyway. :) (ensuring on startup)

j_c_hallgren
XY Blog Master
Posts: 5826
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Post by j_c_hallgren »

admin wrote:
j_c_hallgren wrote:Or...why not just create it via the Installation process, like most other apps do? And have it as empty folder within the no-install process so it would be established then also.
Because I have a no-install package, too. And because I don't like it.
Actually, if you provided a simple sample script or two, then the script folder would be non-empty on install/unload and problem would be solved plus it would give users a demo to begin with... :wink:
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

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

Post by admin »

j_c_hallgren wrote:
admin wrote:
j_c_hallgren wrote:Or...why not just create it via the Installation process, like most other apps do? And have it as empty folder within the no-install process so it would be established then also.
Because I have a no-install package, too. And because I don't like it.
Actually, if you provided a simple sample script or two, then the script folder would be non-empty on install/unload and problem would be solved plus it would give users a demo to begin with... :wink:
Ah, now you are talking. :) Will do...

RalphM
Posts: 2042
Joined: 27 Jan 2005 23:38
Location: Cairns, Australia

Re: Edit: List All Script Files

Post by RalphM »

Since there were some changes to the controls that are focused as a standard, this script didn't work properly anymore.
It needs the additional line focus l; before copying the items to clipboard, 'cos otherwise the tree has the focus and you end up with an error msg.

Code: Select all

"Edit: List All Script Files..."
 // Open New Tab
 #340;
 // goto folder
 goto "<xypath>\Scripts";
 sortby name, a;
 sel 1,0;
 selfilter "*.xys";
 focus l; 
// Copy Item Path/Name(s)
 #101;
 set $script, <clipboard>;
 // Close Tab
 #351;
 regexreplace $script, $script, "^(.+)\\(.+)\.xys$", """Edit $2"" open  ""$1\$2.xys"";";
 load $script,,s;
Ralph :)
(OS: W11 24H2 Home x64 - XY: Current x32 beta - Office 2024 32-bit - Display: 1920x1080 @ 125%)

Post Reply