#Trying to load from multiple folders and adding their contents to an array. (Beginner)

5 messages · Page 1 of 1 (latest)

royal storm
#

I'm looking to load files from multiple folders and to assign their contents to arrays by their folder of origin:

So Staffbases from their folder go into a staffbase array
staffheads from their folder go into a staffhead array and so on.

But I cannot find the right method to this online, I've been looking for days without a solution so here I am asking publicly. I appreciate any help.

strong vigil
#

Just check if the filename contains something specific and append it to the array.
If filename.findn("staffhead"): data.append( file )

royal storm
#

I don't understand how that helps

#

I want this to automatically and dynamically add new arrays based on file contents and not have to manually do it every time i add a new subtype of weaponParts

strong vigil
#

That's the point. You can cycle the entire contents of the folder and check the files, dynamically assigning them based on filenames. If you retain a good naming convention (as it appears you do already) it should be fine