Game Development Community

dev|Pro Game Development Curriculum

Find Unused Assets

by Tom Bampton · 10/22/2004 (6:36 pm) · 14 comments

Download Code File

This perl script scans a TGE or TSE mod directory and tells you what scripts, gui, .dts or .dif files are unused. Finding unused image files is a much more complex job and hasn't been done yet due to time constraints.

The script seems pretty reliable so far. However, you should manually double check everything it tells you before deleting it.

Put the script in your Torque directory, such that starter.fps is accessible through example/starter.fps. There is a variable that sets this path at the top of the script so you can relocate it if needed. Note that you need to specify a mod directory and not the example directory itself, otherwise ~ paths wont work.

Simply type perl FindUnusedAssets.pl at a command prompt/shell to run the script. It should run on any platform that Perl runs on. If you're on windows and don't have Perl installed, you can get a pretty good perl distro at www.activestate.com.

Example output:

D:\Development\BoomBall\BoomBallTGE>perl FindUnusedAssets.pl
Building list of assets ...
Processing Scripts ...
WARNING: FILE ~/data/shapes/test/sphere_all.dts APPEARS TO BE MISSING
Processing Missions ...
Listing Unused Assets ...
[SCRIPT ] Game/demo/server/banlist.cs
[SHAPE  ] Game/demo/data/shapes/logo/torque_logo.dts
[SHAPE  ] Game/demo/data/shapes/rocket_launcher/shell.dts
[SHAPE  ] Game/demo/data/shapes/rocket_launcher/projectile.dts
[SHAPE  ] Game/demo/data/shapes/StadiumGlass/glassEndPanel.dts
[SHAPE  ] Game/demo/data/shapes/StadiumGlass/glassSidePanel.dts
[SHAPE  ] Game/demo/data/shapes/ball/ball_no_col.dts
[SCRIPT ] Game/demo/data/terrains/highplains/propertyMap.cs
[SHAPE  ] Game/demo/data/interiors/boomball/rain3.dif
[SHAPE  ] Game/demo/data/interiors/boomball/rain.dif
[SHAPE  ] Game/demo/data/interiors/boomball/rain4.dif
[SHAPE  ] Game/demo/data/interiors/boomball/rain5.dif
[SHAPE  ] Game/demo/data/interiors/boomball/rain2.dif

Please note that this script was written in about 4 hours to fulfil a need. It is not meant to be a complete and polished tool, so your mileage may vary. Whilst I do intend to add support for images and audio eventually, that may be quite a way off.

#1
10/22/2004 (11:01 pm)
OK why the hell is this under Code Snipits when in fact it's definitely a normal Resource? The resource moderators aren't doing their job!
#2
10/22/2004 (11:56 pm)
Because code snippets are the only resource type that you can attach files to.
#3
10/23/2004 (5:42 am)
Hehe, cool stuff. :) Thanks
#4
10/23/2004 (8:16 am)
More importantly, why aren't you instrumenting the resource manager to determine this? :)
#5
10/23/2004 (9:58 am)
@Ben,

Likely because the resource manager only detects missing files?
In addition, even if you added "find unused files" functionality, you would have to ensure you play your game sufficiently so that all possible assets are loaded during runtime so you could tag them.
#6
10/23/2004 (3:42 pm)
great work ---- I will test it rigth away.
#7
10/24/2004 (2:13 am)
it is perfect ... but can it be expanded to tjeck for jpgs, gif and pngs ? (I haven't coded perl yet )
#8
10/24/2004 (2:46 am)
Ole,

The trouble with images is TGE's convention of not specifying the file extension for the images combined with a billion and one different ways of specifying an image in the scripts. I'm working on it but its slow going :)

Tom.
#9
10/24/2004 (2:52 am)
great ....
#10
10/25/2004 (5:54 am)
And why the hell is Nathan so up in arms... It's like someone broke a cardinal law. Sheesh, man... take a pill already.

- Brett
#11
10/28/2004 (1:30 pm)
This would be cooler if it moved the found unused resources to a "temp" folder instead of deleting. But its still cool.
#12
10/28/2004 (9:41 pm)
It doesnt do anything to them, it just lists them and leaves it up to you to do what you want with them.
#13
11/07/2004 (11:22 am)
Tom,

I just wanted to thank you again for this. Its one of those really useful tools. This really helps keep the ol' working area clean.

Thanks for writting this.

[HOW]EdM|EGTGE
#14
07/25/2006 (2:21 pm)
this looks great.
has anyone extended it to image files ?