Skip to content

Instantly share code, notes, and snippets.

@beardordie
Created July 3, 2019 02:51
Show Gist options
  • Save beardordie/70789564148d9fee424229040b0f0a8f to your computer and use it in GitHub Desktop.
Save beardordie/70789564148d9fee424229040b0f0a8f to your computer and use it in GitHub Desktop.
Unity Editor menu command to select all Empty folders in the project, easily clean them up or find abandoned or forgotten folders. From FPSSample
using System.Collections.Generic;
using UnityEditor;
public static class FindEmptyFolders
{
[MenuItem("Assets/Find Empty Folders")]
static void OnFindEmptyFolders()
{
var empties = new List<UnityEngine.Object>();
foreach (var d in System.IO.Directory.GetDirectories("Assets", "*", System.IO.SearchOption.AllDirectories))
{
if (System.IO.Directory.GetFiles(d).Length == 0)
{
empties.Add(AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(d));
}
}
Selection.objects = empties.ToArray();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment