cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
See how to use to use Text Explorer to glean valuable information from text data at April 25 webinar.
Choose Language Hide Translation Bar
AlanBell
Level II

how can I extract the names of scripts in a folder then execute them?

I am trying to extract the names of files in a subfolder and then extract them,

 

So far I am using the

Files in directory()

 And getting a list and adding to a data table, but I am struggling to get from here to an executable jsl file that will run them all.

 

Any assistance would be great

 

thanks

2 ACCEPTED SOLUTIONS

Accepted Solutions
AlanBell
Level II

Re: how can I extract the names of scripts in a folder then execute them?

When getting files in directory it wasn't including the full path, so I was adding the list to data table and adding the rest of the path and semi colons to get the syntax correct. 

 

I was hoping to include the names as a script with a load of include and file names. And have the file in task scheduler and running every day etc

View solution in original post

Re: how can I extract the names of scripts in a folder then execute them?

lstFiles = Files in Directory ("$SAMPLE_DATA\Loss Function Templates");

for each ({i}, lstFiles,
	//if extension is .jsl, then it's a script, and should be executed
	if (right(i,3)=="jsl", include("$SAMPLE_DATA\Loss Function Templates\"||i));
);

//put values in a new data table
dt = new table ("table",
	new column ("Fname", character, set values (lstFiles))
);

This should be what you're looking for. The bit about putting the list in a table doesn't do anything, other than put them in the table, so unless you actually need the filenames in a table, this can be skipped.

View solution in original post

5 REPLIES 5
jthi
Super User

Re: how can I extract the names of scripts in a folder then execute them?

I don't understand this part: "And getting a list and adding to a data table"

Depending where you are executing the scripts from you can use Include() (files) or << Run Script (table scripts)

-Jarmo
AlanBell
Level II

Re: how can I extract the names of scripts in a folder then execute them?

When getting files in directory it wasn't including the full path, so I was adding the list to data table and adding the rest of the path and semi colons to get the syntax correct. 

 

I was hoping to include the names as a script with a load of include and file names. And have the file in task scheduler and running every day etc

Re: how can I extract the names of scripts in a folder then execute them?

lstFiles = Files in Directory ("$SAMPLE_DATA\Loss Function Templates");

for each ({i}, lstFiles,
	//if extension is .jsl, then it's a script, and should be executed
	if (right(i,3)=="jsl", include("$SAMPLE_DATA\Loss Function Templates\"||i));
);

//put values in a new data table
dt = new table ("table",
	new column ("Fname", character, set values (lstFiles))
);

This should be what you're looking for. The bit about putting the list in a table doesn't do anything, other than put them in the table, so unless you actually need the filenames in a table, this can be skipped.

AlanBell
Level II

Re: how can I extract the names of scripts in a folder then execute them?

Thanks for that, worked great. What are the changes that would cause it to fail in JMP 14 but not 16.

Re: how can I extract the names of scripts in a folder then execute them?

My guess is the For Each loop structure is failing in JMP 14. I think that was added in JMP 15. You can replace that with a traditional For () loop for JMP 14.

Recommended Articles