Is it possible to Loop through script

Hello everyone.

I have a Folder with thousands of subfolders, in each I have 5 STLs,
I need to import every STL from each subfolder and get some data from then to export to text file.

I was wondering if there is a way to import all files in the subfolder, do a lot of things with then and export the data to a text file.
When this is done import the next subfolder and repeat the process, indenting the same text file.

The script for each STL is already done, full of functions and Subs.

Can I make the script do this or is better to make another script and lunch the separate script after each import?
If so how do I make it loop through all the Functions and Subs after each import?

I hope I explained myself right, I’m very new to scripts (started Monday)

Thanks so much
Francisco

Here is a general example of how to iterate through a folder:

https://github.com/mcneel/rhinoscript/blob/master/BatchProcessFiles.rvb

Here are a few more specific examples:

http://wiki.mcneel.com/developer/scriptsamples/batchsavesmall
http://wiki.mcneel.com/developer/scriptsamples/batchrender
http://wiki.mcneel.com/developer/scriptsamples/batchconvertautocad

Thanks for the examples, I think I got it how to loop through the script for each subfolder.

I just have a small problem now, I can’t seem to find anyway how to Import the STL files from the subfolder.
I can only find Open in this exemple https://github.com/mcneel/rhinoscript/blob/master/OpenStlFile.rvb but I can find import.

I want to have 1 rhino file with all the stl. Adding each STL to a diferent layer and naming that layer with the name of the subfolder

Is this possible?

Thanks again

Hi Francisco- try

Rhino.Command “_-Import” & “FilePath”

Does that do what you need?

-Pascal

Attached is are two scripts that do that for different file types, you can look at them and take them apart to see what they do… One imports all files in a folder of a chosen file type (stl included) and puts objects on a layer with the file name, the other does the same, but also preserves any sublayers in a tree structure.

–Mitch

ImportScripts.zip(2.8 KB)

–Mitch