Removing Empty Folders in Unity

This post shares a small (bumeta for empty folderst useful) recipe for getting rid of empty folders in Unity. This annoying thing usually happens when you switch between different git branches, since different branches may add/remove folders.

Git doesn’t like to deal with empty folders, it doesn’t let you delete those empty folders… In case you’ll delete the .meta files, Unity will re-create those later (since the folders still exist).

Show me the code

The code is available in this link: Remove empty folders

Add the class into an editor folder in your project. It will add a new menu item (under Tools/Remove empty folders) that will allow you to remove empty folders.

NOTE: the code contains a dryRun flag that will only iterate and list all the empty folders it’s going to remove. Change this to false to actually make the code delete anything 🙂

This entry was posted in Unity and tagged , , , , . Bookmark the permalink.

One Response to Removing Empty Folders in Unity

  1. Free Debreuil says:

    We had the same sort of issue in our project, we have it run automatically when unity starts, as not everyone using unity is a programmer and would know when to run the script.

Leave a Reply

Your email address will not be published. Required fields are marked *