# Studio script to export audio sizes

**URL:** <https://qa.fmod.com/t/studio-script-to-export-audio-sizes/23718>\
**Category:** FMOD Studio\
**Created:** [November 27, 2025, 1:45pm UTC](https://qa.fmod.com/t/studio-script-to-export-audio-sizes/23718 "2025-11-27T13:45:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![slojanko](https://avatars.discourse-cdn.com/v4/letter/s/fbc32d/32.png) [@slojanko](https://qa.fmod.com/u/slojanko)\
**Post date:** [November 27, 2025, 1:45pm UTC](https://qa.fmod.com/t/studio-script-to-export-audio-sizes/23718/1 "2025-11-27T13:45:59Z")

</div>

Hey,

I’m struggling with the lack of documentation and more detailed examples.

I’m trying to generate a report of all the Assets in our FMOD Studio project, and exporting some information like original asset size, compressed asset size and channel count.

Does anyone have a script that does this, or atleast parts of it? I can’t find a way to iterate over assets before even getting to sizes.

Thanks in advance,  
Janko

---

<div class="post-metadata">

**Author:** ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)\
**Post date:** [November 28, 2025, 3:11am UTC](https://qa.fmod.com/t/studio-script-to-export-audio-sizes/23718/2 "2025-11-28T03:11:01Z")

</div>

Hi!

The simplest way to iterate over all assets is to use either:

```JS
var audioFiles = studio.project.model.AudioFile.findInstances();
audioFiles.forEach(function(audioFile){
    // your code here
});

```

or:

```JS
studio.project.workspace.masterAssetFolder.assets.forEach(function(asset) {
    if (asset.isOfExactType("AudioFile")) {
        // your code here
    }
});

```

Here’s a script that iterates over all AudioFile objects in your project and prints some basic info on each of them:

```JS
studio.menu.addMenuItem({
    name: "Generate Assets Report",
    execute: function() {
        writeLenToFile("AssetsReport");
    }
});

var tab = "\t";
var tabNum = 0;

function writeLenToFile(objectType){

    // Get project path and custom build directory if one is set, and define txt file output path
    var projectPath = studio.project.filePath;
    var projectName = projectPath.substr(projectPath.lastIndexOf("/") + 1, projectPath.length);
    if(typeof studio.project.workspace.builtBanksOutputDirectory == 'undefined'){
        outputPath = projectPath.substr(0, projectPath.lastIndexOf("/") + 1) + objectType + ".txt";
    } else {
        outputPath = studio.project.workspace.builtBanksOutputDirectory + objectType+ ".txt";
    }
    
    // Open txt file at output path, returning early if file cannot be opened
    var textFile = studio.system.getFile(outputPath);
    if (!textFile.open(studio.system.openMode.WriteOnly)) {    
        alert("Failed to open file {0}\n\nCheck the file is not read-only.".format(outputPath));
        console.error("Failed to open file {0}.".format(outputPath));
        return;
    }

    // Write description of info contained in file
    textFile.writeText(objectType + " for '" + projectName +"'\r\n\r\n");

    IterateAudioFiles(textFile);
    
    textFile.close();
    console.log("File containing " + objectType + " successfully created at: " + outputPath);
}

function IterateAudioFiles(textFile){
    var audioFiles = studio.project.model.AudioFile.findInstances();
    audioFiles.forEach(function(audioFile){

        // Write asset path
        textFile.writeText(
            RepeatTab(tabNum) + audioFile.getAssetPath() + "\r\n"
        );

        tabNum++;
        
        // Write asset size
        textFile.writeText(
            RepeatTab(tabNum) + "Asset size: " + (audioFile.frequencyInKHz * audioFile.channelCount * audioFile.length) + "\r\n"
        );

        // Write channel count
        textFile.writeText(
            RepeatTab(tabNum) + "Channels: " + audioFile.channelCount + "\r\n"
        );

        tabNum--;
    });
}

function RepeatTab(n){
    var str = "";
    var i = 0;
    while (i < n){
        str += tab;
        i++
    }
        
    return str;
}

```

You can get additional info on `AudioFile`’s members using `studio.project.model.AudioFile.document()`, or by selecting an asset in the Assets tab and running `studio.window.browserCurrent().dump()`.

That said, unfortunately it currently isn’t possible to retrieve the compressed size of assets via the scripting API. I’ve noted your interest in this feature on our feature tracker.

---

<div class="post-metadata">

**Author:** ![slojanko](https://avatars.discourse-cdn.com/v4/letter/s/fbc32d/32.png) [@slojanko](https://qa.fmod.com/u/slojanko)\
**Post date:** [November 28, 2025, 7:46am UTC](https://qa.fmod.com/t/studio-script-to-export-audio-sizes/23718/3 "2025-11-28T07:46:57Z")

</div>

Thanks for the detailed script.

Later I found the dump() function to atleast get an insight into whats available. Through the getAbsoluteAssetPath I can get the original asset, but the compressed version is still elusive.

Is the “./FMODStudio.cache\fsbcache\Mobile” perhaps something that I could map an asset to? The sizes seem to be smaller than expected, perhaps the compressed cached version of assets?

Not sure how to map an audiofile to names of files in the cache.

Thanks

---

<div class="post-metadata">

**Author:** ![slojanko](https://avatars.discourse-cdn.com/v4/letter/s/fbc32d/32.png) [@slojanko](https://qa.fmod.com/u/slojanko)\
**Post date:** [November 28, 2025, 12:56pm UTC](https://qa.fmod.com/t/studio-script-to-export-audio-sizes/23718/4 "2025-11-28T12:56:05Z")

</div>

I found a workaround, it’s very hackish. If I clear the cache and write a script that iterates over all file and focuses them, Fmod Studio will generate a cache file. I can then rescan the whole folder to find which file was created and I know the mapping.

Please still consider adding this function, as it’s quite critical for any game developer to find the most problematic assets from compression side. If it’s not easy to add the API, then make a workaround so we can get the cached filename, or if that is not possible, just add an export option that generates the a csv report for all assets. There’s a few fallbacks you can consider, that won’t require waiting for the next major release of FMOD.

Thanks

---

<div class="post-metadata">

**Author:** ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)\
**Post date:** [December 1, 2025, 2:24am UTC](https://qa.fmod.com/t/studio-script-to-export-audio-sizes/23718/5 "2025-12-01T02:24:05Z")

</div>

> [@slojanko](#):
>
> I found a workaround, it’s very hackish. If I clear the cache and write a script that iterates over all file and focuses them, Fmod Studio will generate a cache file. I can then rescan the whole folder to find which file was created and I know the mapping.

Happy to hear that it works, despite the hackiness. If possible, could I get you to share your workaround script with me? I’ll add it to the feature tracker as a noted workaround for any future users who want to know the size of their compressed assets.

---

<div class="post-metadata">

**Author:** ![slojanko](https://avatars.discourse-cdn.com/v4/letter/s/fbc32d/32.png) [@slojanko](https://qa.fmod.com/u/slojanko)\
**Post date:** [December 1, 2025, 7:26am UTC](https://qa.fmod.com/t/studio-script-to-export-audio-sizes/23718/6 "2025-12-01T07:26:15Z")

</div>

```javascript
studio.menu.addMenuItem({
name: “CustomTools\Generate report”,
execute: function() {
GenerateReport();
}
});

function GenerateReport() {
// If you’re a javascript enjoyer, fix this, make it relative. I’m not doing it.
// Before running script, make sure to clear all cache inside <cachePath>
var cachePath = “C:/Users/Guest/Git/Project/FMODStudio/.cache/fsbcache/Mobile”;
var outputPath = “C:/Users/Guest/Git/Report.csv”;

var textFile = studio.system.getFile(outputPath);	    
if (!textFile.open(studio.system.openMode.WriteOnly)) {    
	alert("Failed to open file {0}\n\nCheck the file is not read-only.".format(outputPath));
	return;
}

var allAudioFiles = studio.project.model.AudioFile.findInstances();
allAudioFiles.forEach(function(audioFile) {
	var ok = studio.window.navigateTo(audioFile);
	
	var files = studio.system.readDir(cachePath);
	var uncompressed = studio.system.getFile("{0}".format(audioFile.getAbsoluteAssetPath()));
	var compressed = studio.system.getFile("{0}/{1}".format(cachePath, files[2])); // Probably better to iterate over files and skip ./ and ../
	textFile.writeText("{0},{1},{2}\n".format(audioFile.assetPath, uncompressed.size(), compressed.size()));	
	compressed.remove();
});

textFile.close();

}

```

It’s a very lucky script, that navigateTo pauses execution and regenerates cache file, but for us it works in 2.0.3.

On another note while trying to implement this, could you make it easier to “require” general javascript libraries. I accidentally had 2.0.0 API manual open and didn’t see the Dir functions that were added in 2.0.3, so I was trying to somehow import the “fs” lib but there were so many dependencies I would have to manually resolve…

---

<div class="post-metadata">

**Author:** ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)\
**Post date:** [December 4, 2025, 1:04am UTC](https://qa.fmod.com/t/studio-script-to-export-audio-sizes/23718/7 "2025-12-04T01:04:45Z")

</div>

Thanks for the script.

> [@slojanko](#):
>
> On another note while trying to implement this, could you make it easier to “require” general javascript libraries. I accidentally had 2.0.0 API manual open and didn’t see the Dir functions that were added in 2.0.3, so I was trying to somehow import the “fs” lib but there were so many dependencies I would have to manually resolve…

I’ve noted this on our feature tracker, thanks!
