コード例 #1
0
        private void AnalyzeFolder()
        {
            PrepareAnalysis();

            DirectoryInfo info           = new DirectoryInfo(FolderPath);
            var           subdirectories = info.GetDirectories();

            if (subdirectories.Length > 0)
            {
                IsFullShow   = true;
                ShowTitle    = info.Name;
                AddShowTitle = false;

                PreviewFilenames.Add(info.Name);
                RenameFullShow(subdirectories);
            }
            else
            {
                IsSingleSeason = true;
                AddShowTitle   = true;

                var splittedPath = info.FullName.Split(new[] { '\\' }, StringSplitOptions.RemoveEmptyEntries);
                ShowTitle = splittedPath[splittedPath.Length - 1];


                Season = Regex.Match(info.Name, @"\d+").Value;
                int seasonInt;
                if (!int.TryParse(Season, out seasonInt))
                {
                    seasonInt = 1;
                }

                RenameSeason(seasonInt, info);
            }
        }
コード例 #2
0
        private string RenameFile(string name, string oldName, string extention, int season, int episode)
        {
            var newFileName = Pattern.Replace("{title}", name)
                              .Replace("{season}", season.ToString("00"))
                              .Replace("{episode}", episode.ToString("00"))
                              .Replace("{ext}", extention);

            PreviewFilenames.Add($"{oldName} -> {newFileName}");

            return(newFileName);
        }
コード例 #3
0
        private string RenameFolder(string name, int season)
        {
            string newFolderName = $"Season {season.ToString("00")}";

            if (AddShowTitle)
            {
                newFolderName = $"{ShowTitle} - {newFolderName}";
            }

            PreviewFilenames.Add($"{name} -> {newFolderName}");
            return(newFolderName);
        }
コード例 #4
0
        private void FastAnalyzeFolder()
        {
            PrepareAnalysis();

            DirectoryInfo info           = new DirectoryInfo(FolderPath);
            var           subdirectories = info.GetDirectories();

            if (subdirectories.Length > 1)
            {
                PreviewFilenames.Add(info.Name);
                RenameFullShow(subdirectories);
            }
            else
            {
                int seasonInt;
                if (!int.TryParse(Season, out seasonInt))
                {
                    seasonInt = 1;
                }

                RenameSeason(seasonInt, info);
            }
        }
コード例 #5
0
        private void RenameButton_Click(object sender, RoutedEventArgs e)
        {
            foreach (var path in RenameList)
            {
                FileAttributes attr = File.GetAttributes(path.Key);

                if (attr.HasFlag(FileAttributes.Directory))
                {
                    continue;
                }
                else
                {
                    File.Move(path.Key, path.Value);
                }
            }

            foreach (var path in RenameList)
            {
                if (path.Key == path.Value)
                {
                    continue;
                }

                if (Directory.Exists(path.Key) || File.Exists(path.Key))
                {
                    FileAttributes attr = File.GetAttributes(path.Key);

                    if (attr.HasFlag(FileAttributes.Directory))
                    {
                        Directory.Move(path.Key, path.Value);
                    }
                }
            }

            PreviewFilenames.Clear();
            PreviewFilenames.Add("Done");
        }