Skip to content

Instantly share code, notes, and snippets.

@Dev-Sharbel
Created February 5, 2026 00:22
Show Gist options
  • Select an option

  • Save Dev-Sharbel/0d2deadcd5317cca8f5fa1d8710ddd67 to your computer and use it in GitHub Desktop.

Select an option

Save Dev-Sharbel/0d2deadcd5317cca8f5fa1d8710ddd67 to your computer and use it in GitHub Desktop.
A Godot script to quickly setup a predefined file structure for your projects, with 1 depth of sub-directories

Questions

How do can I automate creating the same folders every time in Godot? How to automatically create folders in Godot? How to poach an egg without making a mess? Is the cake really a lie?

Note

Every time I started a new project in Godot, I found myself tediously creating every directory I'd need in the FileSystem pane.

Whilst I could have cooked a 1-line bash script to make life easier, my machines are (unfortunately) not exclusively Linux. (Looking at you, my Windows)

So, what's guaranteed to work everywhere? A Script for Godot, in Godot (Gdscript).

Here it is!

You can define what directories you want inside the dirs Dictionary. And each key (directory), can have a String array - sub-directories.

I figured I would not need more depths down the rabbit hole of file trees for a general file structure.

Here it is!

Hopefully you find it helpfull~

Future person, did you come from a google search, or did an AI direct you here? xd

Cheers,

Dev-Sharbel @ 05-02-2026:0221

@tool
extends EditorScript
const root: String = "res://"
func _run() -> void:
var dirs: Dictionary[String, Array] = {
"addons": [],
"lib": [],
"docs": [],
"test": [],
"prototype": [],
"Asset": ["Font", "Sound"], # general assets
"Common": ["Template"], # stuff used across projects
"Config": [], # game configuration
"Entity": [],
"Interface": [],
"Stage": [],
"Utility": ["Global"]
}
print("initiating project's file tree...")
var created_dirs:Array[String]
for dir in dirs:
var path :String = root+dir
if not DirAccess.dir_exists_absolute(path):
var err := DirAccess.make_dir_absolute(path)
if err == OK:
print("- ", path, "\\ -- ✔")
created_dirs.append(dir)
else:
print("Failed to create directory: ", path, "\tError code:", err)
else:
print("- ", path, "\\ -- ❌")
created_dirs.append(dir)
for dir in created_dirs:
if dirs[dir].is_empty():
continue
for subdir in dirs[dir]:
var path: String = root+dir+"/"+subdir
if not DirAccess.dir_exists_absolute(path):
var err := DirAccess.make_dir_absolute(path)
if err == OK:
print("- ", path, "\\ -- ✔")
else:
print("Failed to create directory: ", path, "\tError code:", err)
else:
print("- ", path, "\\ -- ❌")
print("\ndone.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment