The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

I have a following function in my scene, which scans directories for files of specified format.

func list_files_in_directory(path , type):
var files = []
var dir =
while true:
    var file = dir.get_next()
    if file == "":
    elif not file.begins_with("."):
        if file.ends_with(type):
return files

Example command:

print(list_files_in_directory("res://audio", ".wav"))

Will return this:

[goodluck.wav, laugh.wav, missing.wav, noise.wav, takeout.wav]

Which is correct. Such directory as "res://audio" has exactly 5 .wav files. (It excepts .import files, so everything works as intended)

The problem comes out when I export the project as .exe on Windows.
Without changing anything in code, after opening this scene, function returns value with empty array i.e


Am I missing something ?

I tried defining it within both _ready() and _process() functions, neither of them return expected value.

Godot version: Godotv3.0.6-stablewin64

in Engine by (102 points)

Just created a quick sample project on Linux and I'm running into the same issue. Here is a list of everything in the res:// directory in a compiled Godot project:


It's of course missing Alesis-Fusion-Acoustic-Bass-C2.wav.

I wonder if it's wrapped into project.binary.

At first I thougth it might be something with audio files, but no. I don't quite understand how your output returns other than .import files. I did remove format check statement and added other files like .ogg and .png to test it out. It's something I guess... but I only got .import files written in my array by executable.

I'm completely lost. I also tried to make fresh project and scan res://. Now I understand why all files showed up in your example. Also i've put custom image inside res:// this time, and well...

[, Node.gdc, Node.tscn, spike.png.import, default_env.tres, icon.png, icon.png.import, project.binary]

It's obvious how spike.png is missing, but why icon.png IS !? What's the difference!?

1 Answer

0 votes
Best answer
by (173 points)
selected by

I guess with all my "love" for workarounds that's the best possible way to solve this problem right now. Thanks.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.