cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Use World Cup data to build models, explore spatial relationships, and create informative visualizations in JMP. Register. July 17, 2 pm US Eastern Time.
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

Solve problems, and share tips and tricks with other JMP users.
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