batch scripts continued

In the previous post about batch scripts, I demoed a small script that I use to archive finished projects that removes the temp folders that Unreal Engine creates. I was then reminded by my friend Jenni (you can see her comment on that post) that the light builds are also notoriously massive files.

So let’s expand on that previous batch script and add the line to also search and delete the auto-created light build files.
Here is what we ended up with for removing only the temp folders script:

FOR /d /r %%d IN ("Binaries","Build","Intermediate","Saved") DO @IF EXIST "%%d" rd /s /q "%%d"

And now what I would like to add next is the line to delete any file it finds that ends with “_BuiltData.uasset” which just happens to be the generated light builds.

We will use the DEL command and the options we will set are:

/F : Ignore read-only setting and delete anyway (FORCE)
/S : Delete from all Subfolders (DELTREE)
/Q : Quiet mode, do not give a Yes/No Prompt before deleting
* : A wildcard. In this example, we use: *_EndsWith* indicating that the file ends with this string, but can contain anything else before it.
REM : Human readable string that ignored by the script

Putting this together looks like this:

DEL /F /S /Q *_BuiltData.uasset*

Now we can combine this one with our previous one, add some comments like a good programmer, and boom!

REM Quietly and recursively removes generated temp folders with specific names. 
REM Can change the folder names to add/remove any to fit needs.
REM BeginScript:
FOR /d /r %%d IN ("Build","Intermediate","Saved") DO @IF EXIST "%%d" rd /s /q "%%d"

REM Quietly and recursively removes the generated light builds by force  
DEL /F /S /Q *_BuiltData.uasset*

To learn how to use this script, follow directions in the previous post about batch scripts.

Happy scripting!

Site Footer