Unity Libraries Cleaner - Free Batch Script to Save Space

Do you need space on your drives? Do you have a lot of Unity projects on your computer? Did you notice that Library folders are often over 1 Gb each?

As a teacher, my disk fills up quite fast when I open all my students’ projects. At the end of the semester, I need a real clean up! That’s why I created Unity Libraries Cleaner, a batch script that can easily delete the contents of Library folders, without erasing precious projects! (Don’t worry, when you open a project, Unity can always rebuild the content of the Library folder.)

https://github.com/JonathanTremblay/UnityLibrariesCleaner

Instructions:

  • The .bat file must be placed in a folder containing one or more Unity projects (make sure you have write access for this folder).
  • Double-click the UnityLibrariesCleaner.bat script to make it run.
  • If Windows prevents the script from running, click “More info” and then “Run anyway” (don’t take my word for it, take a look at the code first!)
  • The script finds all valid Library folders and then offers Manual or Automatic mode.
  • Then the contents of the folders are permanently deleted (not placed in the trash).
  • The “Library/LastSceneManagerSetup.txt” files are kept (these files are used to keep the last scene opened for each project).

If you like to save space, also take a look at my free Export Project to Zip on the Unity Asset Store! (More info in that post: Export Project to Zip - Unity Editor Free Tool )

2 Likes

It says error

‘et’ is not recognized as an internal or external command,
operable program or batch file.
‘et’ is not recognized as an internal or external command,
operable program or batch file.
‘em’ is not recognized as an internal or external command,
operable program or batch file.
‘em’ is not recognized as an internal or external command,
operable program or batch file.
‘or’ is not recognized as an internal or external command,
operable program or batch file.
‘em’ is not recognized as an internal or external command,
operable program or batch file.
‘hcp’ is not recognized as an internal or external command,
operable program or batch file.
‘em’ is not recognized as an internal or external command,
operable program or batch file.

1 Like

Hi @Zankenpon,
Thank you for your feedback. You probably have files with paths longer than 260 characters. This is a known issue due to an OS limitation (GitHub - JonathanTremblay/UnityLibrariesCleaner: A Batch Script to free up disk space by emptying the Library folders of your Unity projects.). Can you try to shorten your paths? You can also try to remove any accented characters from the paths. If it doesn’t solve the problem, please give me some examples of your file paths, I would like to find a solution! :slightly_smiling_face:

Version 1.0.2 of the script is available. It now detects folder path length to avoid execution issues.
If you encounter any errors or have any questions, please let me know! :slightly_smiling_face:

1 Like

hey thanks for the fix, turns out at that time my folder had ‘!’ in front of the first root folder so it refused to execute.

1 Like

Version 1.0.3 of the script is available.
It now detects the cumulative total of all paths to avoid problems associated with exceeding the 8192-character limit for variables in a .BAT script. This makes it possible to clean up disks containing more Unity projects, without crashing.
Also, the interface now indicates a counter during folder discovery and deletion.
Finally, folders containing exclamation marks should no longer cause crashes, but they are not processed either (in any case, I recommend all developers to avoid exclamation marks in paths!)
If you discover any problems, please let me know! :slightly_smiling_face: