Is there a Python script for gathering all level assets (incl. materials/meshes/blueprints etc)

Hey guys, noob question regarding Python scripts…

Is there a Python script for gathering all level assets (including materials/meshes/blueprints etc) and putting them all into a folder?

I tried using the ‘DeleteUnusedAssets’ script earlier on my Content folder (as I have tons of asset packs in my project) but then quickly realised that the script was only removing assets that had literally 0 links to them (so textured meshes, material instances, blueprints etc would all still remain) even though I’m not actually using all of the assets in ‘my’ levels.

What I wanted to do was run a script on my level and package all the used assets/materials/textures into one place, then i could delete all the asset packs in my project, leaving only what I am actually using.

Is this even possible, or should I start the long and tedious process of manually isolating each asset to trace back all its links etc and saving them out one by one?

Really hope someone can help me out here.

Many thanks,
Jon

I have not tried it myself but you can take a look at this post: Capture all asset references - Editor Scripting - Unreal Engine Forums

I think you can use this to try to replicate what the built-in Reference Viewer does. I would try passing in your map asset as the ‘root’ object. Then, recursively call getDep() on the return list to get their dependencies. You’ll need to choose how many levels deep to go. Once you have this master list of referenced assets in the map, then iterate all assets like in DeleteUnusedAssets.py. If it is not in the master list, then delete.