static void Run(string[] args)
        {
            string inDir, outCat, outDir;

            Console.WriteLine("Please enter the input directory");
            inDir = Console.ReadLine();
            Console.WriteLine("Please enter the output category (or leave blank to choose per item)");
            outCat = Console.ReadLine();
            Console.WriteLine("Please enter the output directory");
            outDir = Console.ReadLine();

            foreach (string path in Directory.EnumerateFiles(inDir))
            {
                string fileName = path.Split('\\').Last();
                if (path.ToLowerInvariant().EndsWith(".mdb"))
                {
                    string[] nameParts = fileName.Split('_');
                    string   newName;
                    if (nameParts.Length != 4)
                    {
                        Cloaktower.CTDebug.Warn("Encountered bad filename: {0}", fileName);
                        File.Copy(path, Path.Combine(outDir, fileName), true);
                        continue;
                    }
                    else
                    {
                        nameParts[2] = outCat;
                        newName      = string.Join("_", nameParts);
                    }
                    MdbDocument doc = new Cloaktower.MDB.MdbDocument(path);
                    doc.Read(path);

                    string filePrefix = fileName.Split('.')[0];
                    foreach (MdbPacket packet in doc.GetPackets())
                    {
                        if (packet is NamedMdbPacket)
                        {
                            NamedMdbPacket named = (NamedMdbPacket)packet;
                            if (named.Name.Contents.ToLowerInvariant() == (filePrefix.ToLowerInvariant()))
                            {
                                string[] subNameParts = named.Name.Contents.Split('_');
                                subNameParts[2]     = outCat;
                                named.Name.Contents = string.Join("_", subNameParts);
                            }
                        }
                    }
                    doc.Write(Path.Combine(outDir, newName));
                }
                else
                {
                    File.Copy(path, Path.Combine(outDir, fileName), true);
                }
            }
        }
Esempio n. 2
0
        public static void Run(string[] args)
        {
            string inDir = "in", outDir = "out";

            //Console.WriteLine("Please enter the input directory");
            //inDir = Console.ReadLine();
            //Console.WriteLine("Please enter the output directory");
            //outDir = Console.ReadLine();

            foreach (string path in Directory.EnumerateFiles(inDir))
            {
                string fileName = path.Split('\\').Last();
                if (path.ToLowerInvariant().EndsWith(".mdb"))
                {
                    MdbDocument doc = new Cloaktower.MDB.MdbDocument(path);
                    doc.Read(path);
                    doc.Write(Path.Combine(outDir, fileName));
                }
                else
                {
                    File.Copy(path, Path.Combine(outDir, fileName), true);
                }
            }
        }
Esempio n. 3
0
        public static void Run(string[] args)
        {
            string inDir, outDir;
            int    increment;

            inDir = "in";
            Console.WriteLine("Please enter how many lines to increment");
            increment = Int32.Parse(Console.ReadLine());
            //Console.WriteLine("Please enter the output directory");
            outDir = "out";

            foreach (string path in Directory.EnumerateFiles(inDir))
            {
                string fileName = path.Split('\\').Last();
                if (path.ToLowerInvariant().EndsWith(".mdb"))
                {
                    string[] nameParts = fileName.Split('.')[0].Split('_');
                    string   newName;
                    string   newNumberPart;
                    if (nameParts.Length != 4)
                    {
                        Cloaktower.CTDebug.Warn("Encountered bad filename: {0}", fileName);
                        File.Copy(path, Path.Combine(outDir, fileName), true);
                        continue;
                    }
                    else
                    {
                        string numberPart  = nameParts[3];
                        int    numberIndex = numberPart.IndexOfAny(new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }, 0);
                        int    number      = int.Parse(numberPart.Substring(numberIndex, numberPart.Length - numberIndex)) + increment;
                        newNumberPart = numberPart.Substring(0, numberIndex) + (number < 10?"0":"") + (number.ToString());

                        nameParts[3] = newNumberPart;
                        newName      = string.Join("_", nameParts);
                    }
                    MdbDocument doc = new Cloaktower.MDB.MdbDocument(path);
                    doc.Read(path);

                    string filePrefix = fileName.Split('.')[0];
                    foreach (MdbPacket packet in doc.GetPackets())
                    {
                        if (packet is NamedMdbPacket)
                        {
                            NamedMdbPacket named = (NamedMdbPacket)packet;
                            if (named.Name.Contents.ToLowerInvariant() == (filePrefix.ToLowerInvariant()))
                            {
                                string[] subNameParts = named.Name.Contents.Split('_');
                                subNameParts[3] = newNumberPart;
                                CTDebug.Info("Renaming {0} to {1}", named.Name.Contents, string.Join("_", subNameParts));
                                named.Name.Contents = string.Join("_", subNameParts);
                            }
                        }
                    }
                    doc.Write(Path.Combine(outDir, newName + ".MDB"));
                }
                else
                {
                    File.Copy(path, Path.Combine(outDir, fileName), true);
                }
            }
        }
Esempio n. 4
0
        public static void Run(string[] args)
        {
            string inDir = "in", outDir = "out";

            //Console.WriteLine("Please enter the input directory");
            //inDir = Console.ReadLine();
            //Console.WriteLine("Please enter the output directory");
            //outDir = Console.ReadLine();

            foreach (string path in Directory.EnumerateFiles(inDir))
            {
                string fileName = path.Split('\\').Last();
                if (path.ToLowerInvariant().EndsWith(".mdb"))
                {
                    string[] nameParts = fileName.Split('.')[0].Split('_');
                    string   newName;
                    int      number;
                    if (nameParts.Length != 3)
                    {
                        Cloaktower.CTDebug.Warn("Encountered bad filename: {0}", fileName);
                        File.Copy(path, Path.Combine(outDir, fileName), true);
                        continue;
                    }
                    else
                    {
                        number       = int.Parse(nameParts[2].Substring(4, 2)) + 30;
                        nameParts[2] = nameParts[2].Substring(0, 4) + (number).ToString();
                        newName      = string.Join("_", nameParts);
                    }
                    MdbDocument doc = new Cloaktower.MDB.MdbDocument(path);
                    doc.Read(path);

                    string filePrefix = fileName.Split('.')[0];
                    foreach (MdbPacket packet in doc.GetPackets())
                    {
                        if (packet is NamedMdbPacket)
                        {
                            NamedMdbPacket named = (NamedMdbPacket)packet;
                            if (named.Signature == "SKIN")
                            {
                                string[] split = named.Name.Contents.Split('_');
                                split[2] = split[2].Substring(0, split[2].Length - 2) + (number).ToString();
                                string newInternalName = named.Name.Contents.Substring(0, named.Name.Contents.Length - 2) + (number).ToString();
                                CTDebug.Info("Renaming {0} to {1}", named.Name.Contents, newInternalName);
                                named.Name.Contents = newInternalName;
                                if (split[2].Substring(0, 4) == "Head" && split.Length == 3)
                                {
                                    newName = newInternalName;
                                }
                            }
                            else if (named.Signature == "RIGD")
                            {
                                CTDebug.Warn("Found a RIGD in {0}", fileName);
                            }
                        }
                    }
                    doc.Write(Path.Combine(outDir, newName + ".mdb"));
                }
                else
                {
                    File.Copy(path, Path.Combine(outDir, fileName), true);
                }
            }
        }