Ejemplo n.º 1
0
        public static void RenameFiles(string srcPath, string replaceFrom, string replaceTo)
        {
            var files = ProcessFiles.GetFiles(srcPath, SearchOption.AllDirectories, new string[] { "MKV" });

            foreach (var file in files)
            {
                var oldfile     = file.Name;
                var newFile     = (oldfile.Contains(replaceFrom)) ? oldfile.Replace(replaceFrom, replaceTo) : oldfile;
                var newFileFull = $"{file.Directory}\\{newFile}";
                File.Move(file.FullName, newFileFull);
            }
        }
Ejemplo n.º 2
0
        public static string ExecuteProcessFiles(string srcPath, string destFilePath, FileType fileType, bool?allDirectories)
        {
            var searchOption = (allDirectories ?? false) ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;

            var sb        = new StringBuilder();
            var pf        = new ProcessFiles();
            var fileBatch = 45000;// 8500;

            if (fileType == FileType.Photos)
            {
                var extentions = Constants.PhotoExt;
                sb.Append(pf.MoveFiles(srcPath, destFilePath, fileBatch, searchOption, extentions));
            }

            else if (fileType == FileType.Videos)
            {
                var extentions = Constants.VideoExt;
                pf.DirectorySearch(srcPath, destFilePath, fileBatch, extentions, searchOption);
                pf.MoveMovies(srcPath, destFilePath, fileBatch, extentions, searchOption);
            }
            else if (fileType == FileType.Music)
            {
                var extentions = Constants.MusicExt;
                pf.MoveMusic(srcPath, destFilePath, fileBatch, searchOption, extentions);
            }
            else if (fileType == FileType.Any)
            {
                pf.MoveFiles(srcPath, destFilePath, fileBatch, searchOption, null, true);
            }
            else
            {
                throw new NotImplementedException($"FileType: {fileType} not defined. Defined FileType: {FileType.Photos} and {FileType.Videos}");
            }

            var line = "* Process Completed";

            Console.WriteLine(line); sb.AppendLine(line);
            Console.Read();

            return(sb.ToString());
        }