diff --git a/IPASorter.sln b/IPASorter.sln new file mode 100644 index 0000000..e11ed7a --- /dev/null +++ b/IPASorter.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31624.102 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IPASorter", "IPASorter\IPASorter.csproj", "{A79DAC1B-2AFF-45B6-B63F-92B90D3EFC74}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A79DAC1B-2AFF-45B6-B63F-92B90D3EFC74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A79DAC1B-2AFF-45B6-B63F-92B90D3EFC74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A79DAC1B-2AFF-45B6-B63F-92B90D3EFC74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A79DAC1B-2AFF-45B6-B63F-92B90D3EFC74}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {EB55AD64-EE03-4C37-B92A-90698C71A4A2} + EndGlobalSection +EndGlobal diff --git a/IPASorter/FileClass.cs b/IPASorter/FileClass.cs new file mode 100644 index 0000000..fa6fb3f --- /dev/null +++ b/IPASorter/FileClass.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace IPASorter +{ + public class IPAFile + { + public string path { get; set; } + public string md5sum { get; set; } + public string fileName { get; set; } + } +} diff --git a/IPASorter/IPASorter.csproj b/IPASorter/IPASorter.csproj new file mode 100644 index 0000000..c73e0d1 --- /dev/null +++ b/IPASorter/IPASorter.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + diff --git a/IPASorter/Program.cs b/IPASorter/Program.cs new file mode 100644 index 0000000..1062257 --- /dev/null +++ b/IPASorter/Program.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Security.Cryptography; +using System.Text; +using System.Threading.Tasks; + +namespace IPASorter +{ + class Program + { + // renaming format: "com.bundle.id-1.0-(iOS4.3).ipa" + + public static List files = new List(); + static void Main(string[] args) + { + Console.WriteLine("IPASorter by KawaiiZenbo"); + // parse filepath if given + string argsFilePath = args.Length != 0 ? args[0] : "./"; + if (!argsFilePath.EndsWith("/") || !argsFilePath.EndsWith("\\")) argsFilePath += "/"; + + // create temp dir + if (Directory.Exists("%appdata%/IPASorterTemp/")) Directory.CreateDirectory("%appdata%/IPASorterTemp/"); + + // run steps + FileScanner(argsFilePath); + MD5Eliminator(); + + //done + if (Directory.Exists("%appdata%/IPASorterTemp/")) Directory.Delete("%appdata%/IPASorterTemp/"); + Console.WriteLine("complete :)"); + } + + // step 1 + static void FileScanner(string path) + { + List tmp = Directory.GetFiles(path, "*.ipa", SearchOption.AllDirectories).ToList(); + foreach (string s in tmp) + { + files.Add(new IPAFile + { + fileName = s.Split('/')[s.Split('/').Length -1].Split('\\')[s.Split('/')[s.Split('/').Length - 1].Split('\\').Length - 1], + path = s, + md5sum = CalculateMD5(s) + }) ; + } + } + + // step 2 + static void MD5Eliminator() + { + foreach (IPAFile i in files) + { + Console.WriteLine($"checking against {i.path} ({i.md5sum})"); + } + } + + // step 3 + static void InfoPlistEliminator() + { + + } + + // step 4 + static void InfoPlistRenamer() + { + foreach (IPAFile i in files) + { + File.Move(i.path, i.path.Replace(i.fileName, "")); + } + } + + // step 5??? + static void Sort() + { + + } + + // misc functions + static string CalculateMD5(string fileName) + { + using (var md5 = MD5.Create()) + { + using (var stream = File.OpenRead(fileName)) + { + var hash = md5.ComputeHash(stream); + return BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant(); + } + } + } + } +} +