Skip to content

Instantly share code, notes, and snippets.

Last active May 5, 2023 19:56
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Extract Texture Report csv from UE4 Memreport
# Copyright: Jonas Reich 2021
# Extracts the texture report table from UE4 .memreport files and stores them as separte csv files.
# Uses semicolon delimiters and opens the extracted file with its default application (for me: Excel)
[Parameter(Mandatory=$true,ValueFromPipeline = $true)]
$ErrorActionPreference = "Stop"
if(-not $SourceFile.EndsWith(".memreport")) {
Write-Error "'$SourceFile' does not end with memreport extension. Please only pass UE4 memreport files!"
$SourceFileName = [io.path]::GetFileNameWithoutExtension($SourceFile)
$SourceFileDir = Split-Path $SourceFile -Parent
$TargetFile = "$SourceFileDir\$SourceFileName.csv"
if(Test-Path $TargetFile){
Clear-Content -Path $TargetFile
} else {
New-Item $TargetFile
$FileContent = Get-Content $SourceFile -Raw
if($FileContent -match "(?sm)Listing all textures\.(?<TextureReport>.*)Total size: ") {
$TextureReport = $Matches.TextureReport
} else {
Write-Error "Failed to extract texture report from memreport"
# Format:
# Cooked/OnDisk: Width x Height (Size in KB, Authored Bias), Current/InMem: Width x Height (Size in KB), Format, LODGroup, Name, Streaming, Usage Count
"disksize_x;disksize_y;disksize_kb;bias;memsize_x;memsize_y;memsize_kb;texformat;texgroup;path;bstreaming;usagecount" | Add-Content $TargetFile
$AllLines = $TextureReport -Split [Environment]::NewLine
$NumLines = $AllLines.Length
$LineNr = 0
foreach ($Line in $AllLines) {
if($Line.Length -eq 0) {
if($Line -match "(?<disksize_x>\d+)x(?<disksize_y>\d+) \((?<disksize_kb>\d+) KB, (?<bias>.?)\), (?<memsize_x>\d+)x(?<memsize_y>\d+) \((?<memsize_kb>\d+) KB\), (?<texformat>\w+), TEXTUREGROUP_(?<texgroup>\w+), (?<path>.+?), (?<bstreaming>\w+), (?<usagecount>\d+)")
$disksize_x = $Matches.disksize_x
$disksize_y = $Matches.disksize_y
$disksize_kb = $Matches.disksize_kb
$bias = $Matches.bias
$memsize_x = $Matches.memsize_x
$memsize_y = $Matches.memsize_y
$memsize_kb = $Matches.memsize_kb
$texformat = $Matches.texformat
$texgroup = $Matches.texgroup
$path = $Matches.path
$bstreaming = $Matches.bstreaming
$usagecount = $Matches.usagecount
$NewLine = "$disksize_x;$disksize_y;$disksize_kb;$bias;$memsize_x;$memsize_y;$memsize_kb;$texformat;$texgroup;$path;$bstreaming;$usagecount"
$NewLine | Add-Content $TargetFile
elseif($LineNr -ne 0)
Write-Error "Could not parse line '$Line'"
$ProgressPercent = [math]::floor([decimal](($LineNr / $NumLines) * 100))
Write-Progress -Activity "Extracting texture report to csv" -Status "$ProgressPercent% Complete ($LineNr / $NumLines):" -PercentComplete $ProgressPercent;
"Saved texture report to $TargetFile"
Invoke-Item $TargetFile
:: Copyright: Jonas Reich 2021
:: Utility script for easier execution of main Powershell script that allows extracting a memreport by drag & drop.
:: Also simplifies executing the ps1 script on systems that do not regularly allow ps1 script execution.
@echo off
if "%1"=="" goto error
goto noerror
echo error: must specify source file (drag and drop a memreport file onto the cmd script or specify it as first parameter)
exit 1
@echo on
powershell -ep RemoteSigned "%~dp0ExtractTextureReportFromMemreport.ps1" "%1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment