emoose / MBINCompiler

Now maintained by monkeyman192: https://github.com/monkeyman192/MBINCompiler
Other
43 stars 69 forks source link

Batch compile / decompile #61

Closed dsuurlant closed 7 years ago

dsuurlant commented 7 years ago

Not all templates are mapped yet, but lots are, and a batch functionality would be really helpful at this point. Being able to grep all the XML will make it easier for modders to find what they need. I'd like to take a crack at it myself.

hhrhhr commented 7 years ago

something like this one-line command?

for /r "...\NMS_unpacked_dir\" %i in ("*.MBIN") do @MBINCompiler.exe "%i"
for /r "...\NMS_unpacked_dir\" %i in ("*.exml") do @MBINCompiler.exe "%i"
Bananasft commented 7 years ago

something like this one-line command?

Pretty much this, you are also able to pass an output path as second argument.

Meaning you could do something like this:

$inPath = "C:\NMS\unpacked";
$outPath = "C:\NMS\unpacked_exml";
$mbinCompiler = "C:\NMS\tools\MBINCompiler.exe";

Get-ChildItem $inPath -Filter *.mbin -Recurse | % { 
    $outDir = $_.Directory.FullName.Replace($inPath, $outPath);
    if(!(Test-Path $outDir))
    {
        New-Item $outDir -ItemType Directory  | Out-Null
    }

    $mbinFile = "`"$($_.FullName)`" ";
    $exmlFile = "`"$outDir\$($_.Name.Replace(".MBIN",".exml"))`"";

    & $mbinCompiler $mbinFile $exmlFile
}

(This can also be found here.)

A few more lines but it recursively decompiles every mbin in one folder into another.

dsuurlant commented 7 years ago

I was thinking inside the application code, but that works too, thanks!