//0 is start time, 1 is end time
        public static async Task <bool> Sort(string Path, string OutputPath)
        {
            DateTime startTime = DateTime.Now;

            MConsole.WriteLine($"Please wait, copying files from:\n{Path}\nto:\n{OutputPath}");
            string[] cacheFiles  = Directory.GetFiles(Path);
            int      cl          = (int)(((float)cacheFiles.Length) * 0.1f);
            string   currentName = "";

            for (int i = 0; i < cacheFiles.Length; i++)
            {
                currentName = DecryptFileName(cacheFiles[i]);
                await CopyFileAsync(cacheFiles[i], OutputPath + "/" + Regex.Replace(currentName, "(https|http)://.*.com/", ""));

                if (i % cl == 0)
                {
                    MConsole.WriteLine((int)Mathf.Clamp(value: ((float)i / (float)cacheFiles.Length) * 100, min: 0, max: 100) + "% | " + i + "/" + cacheFiles.Length);
                }
            }
            TimeSpan calcedTime = DateTime.Now - startTime;

            MConsole.WriteLine($"Done!\nWork time:\n[ Hours: {calcedTime.Hours} | Minutes: {calcedTime.Minutes} | Seconds: {calcedTime.TotalSeconds} ]", ConsoleColor.Magenta);
            GC.Collect();
            return(true);
        }
Example #2
0
        static async Task Main(string[] args)
        {
            string[] cfg = File.ReadAllLines("Config.txt");
            #region Cache Folder Select
            MConsole.WriteLine("Use default path to cache folder? Y\\N");
            if (Utils.YNorUnknown(Console.ReadLine()[0]) == 1)
            {
                Settings.CurrentPathToCacheFolder = cfg[0];
            }
            MConsole.WriteLine("Setted path:\n" + Settings.CurrentPathToCacheFolder + "\n", ConsoleColor.Green);

            #endregion

            #region Output Folder Select
            MConsole.WriteLine("Use default output folder? Y\\N");

            if (Utils.YNorUnknown(Console.ReadLine()[0]) == 1)
            {
                Settings.CurrentPathToCacheFolder = cfg[1];
                MConsole.WriteLine("Setted path:\n" + Settings.CurrentPathToCacheFolder + "\n", ConsoleColor.Green);
            }
            MConsole.WriteLine("Setted path:\n" + Settings.CurrentPathToCacheFolder + "\n", ConsoleColor.Green);
            if (Directory.Exists(Settings.CurrentOutputPath) &&
                (Directory.GetFiles(Settings.CurrentOutputPath).Length != 0 ||
                 Directory.GetDirectories(Settings.CurrentOutputPath).Length != 0))
            {
                MConsole.WriteLine("Delete files in output path!", ConsoleColor.Red);
                Console.ReadLine();
                return;
            }

            MConsole.WriteLine("Setted path:\n" + Settings.CurrentOutputPath + "\n", ConsoleColor.Green);
            #endregion

            await Cache.Sort(Settings.CurrentPathToCacheFolder, Settings.CurrentOutputPath);
        }