Get Current Directory, Get Files and File Count

eagleeyez 4 years ago updated by Lazlo Bonin (Lead Developer) 4 years ago 12

Get Current Directory, Get Files and File Count

Hi, I am trying something out but just don’t know how to use the units. I have added to ludig the IO, directories, directory info, files and file info. So I get the IO I need.

At first I get the current directory and show to log. That shows me the current directory.

Now I want to get the files into a list and display these one after the other in the log and at the end show the file count.

If I could understand this I would get on further with other things. In playmaker I can do this very easily indeed.

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):

Simple. Connect the output list on the get files unit to a for each loop. In the body use a log message with the current file as the input from the loop Then on exit connect a log message. Use the output of get files and connect a get count unit. Connect that output to the exited message.

Make sense? Not at my computer, I'll grab a photo later if need be.

Hey thanks for that. I did this and it works but I still don't know how to actually save the vars to a list, as I have no lists in my object variables inspector.

It's doing my head in now. How do I get collections, lists in my variable window?

I cannot save my items with the index to a list as I cannot create a dam list in variables.

If there were only just more info or tutorials.

2 things. Lists are by type. So you needed to find List<string> or List<int> ect. Not just a plane List. And you can create and set a new variable and it'll show up in the variables tab at runtime, without needing to know the type being saved. Just attach your list to the set variable. Or as you loop, in the body (if you created the list variable already), do collections>list>add item. 

If you're looking to have a key to search mapped to another type, try dictionaries instead.

Not sure I totally get the issue, so if I missed something I'll try to help more.

Sorry, nothing like that by mie. Please post a picture of a working set list, just like mine above but to save to a list. I am really getting to the end of my nervs today, just because I cannot for the life of me make a list. And wher is List<String> nothing showing up nowhere in my bolt.

I use programming terms, not Human Naming. That is why. It will probably just be List String, or String List, of some sort. Anyways, if you want to assign all the paths directly as a list, do this.

If you want to assign a List before you click the play button, do this in the variables inspector, under any variable scope. 

And then Assign the ones from the directory individually, to a new list, by first retrieving the current list, and adding the rest on to it. re-set the variable with the new list you created.


Well JasonJonesLASM, the old saying a picture speaks more than a thousand words is in deed true. I understood what was going on in 3 seconds of looking at your screenshot and also realized what I was doing wrong and that setting lists in my variables windows was missing. I new one could set it directly without declaring and now I know how.

Thanks a bunch, I'll be making a video about this later on.

p.s. I am loving this community as everyone seams to be chipping in and helping, even me.

Coming from Playmaker it just seams strange to have to get the variable before setting the variable. Why not just set variable and be done with it? It must know that what I am setting is what should be set. For me it just looks like an extra node.

But OK, here it is done like that, so who am I to complain.

Thanks again for taking the time to help me.

Honestly, try without the set variable. Might not need that. You use get so you can get a reference to that being the list you're using and assigning with. The list being just the function you're executing. Without the get, you have a null list. 

Never used play maker, but I'd bet when setting, it would be doing exactly what's happening here, just hidden from the user in one block.


Indeed, you don't need the Set Variable unit there. The list is passed by reference in Add Item, meaning the actual instance is being updated instead of creating a new copy with the added item.

I switched to programmer naming and now all is there. Much better thank you.

You should have everything in Human Naming as well; please let me know if you don't even in v.1.0.4.