The Forum is up for sale: XeNTaX Forum looking for new owner

Life After mesh model file

Post questions about game models here, or help out others!
User avatar
Durik256
ultra-veteran
ultra-veteran
Posts: 425
Joined: Wed Nov 21, 2018 7:26 pm
Has thanked: 45 times
Been thanked: 411 times

Re: Life After mesh model file

Post by Durik256 »

Xr79 wrote: Fri Dec 02, 2022 3:05 am i know that they are .mesh files
but there may be textures and other files. I made a console application that changes the extension depending on the first 4 bytes of 'magic'. maybe [.mesh, *.dds, *.gis], other files will remain unchanged.
just drop a file or directory on it and it will scan all the files in the folder.
tested on "_Unknow" folder.
source code:

Code: Select all

using System;
using System.IO;
using System.Text;

namespace ConsoleRenamer
{
    internal class Program
    {
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                bool flag = File.GetAttributes(args[0]).HasFlag(FileAttributes.Directory);
                string[] files = Directory.GetFiles(flag ? args[0] : Path.GetDirectoryName(args[0]));

                foreach (string file in files)
                {
                    uint magic;

                    using (BinaryReader br = new BinaryReader(File.OpenRead(file), Encoding.UTF8))
                        magic = br.ReadUInt32();

                    switch (magic)
                    {
                        case 1397311314:
                            rename(file, ".gis");
                            break;
                        case 542327876:
                            rename(file, ".dds");
                            break;
                        case 3150479412:
                            rename(file, ".mesh");
                            break;
                    }
                }
            }
            Console.ReadKey();
        }

        static void rename(string name, string ext)
        {
            File.Move(name, Path.ChangeExtension(name, ext));
            Console.WriteLine($"{name} >> {ext}");
        }
    }
}
You do not have the required permissions to view the files attached to this post.
Post Reply