public void GetFileToDelete(ref TagKeyValuePair KeyValuePair)
 {
     if (!this._Value.isDuplicate)
     {
         if (!this._Value.isOriginal)
         {
             RFile temp = KeyValuePair._Value;
             if (!temp.Corrupt && _Value.Corrupt)
             {
                 SwopValue(ref KeyValuePair);
             }
             else if (!temp.Corrupt)
             {
                 if (temp.Tag.Bitrate < this._Value.Tag.Bitrate)
                 {
                     SwopValue(ref KeyValuePair);
                 }
                 else if (temp.Tag.Duration < this._Value.Tag.Duration)
                 {
                     SwopValue(ref KeyValuePair);
                 }
                 else if (temp.isOriginal)
                 {
                     SwopValue(ref KeyValuePair);
                 }
             }
         }
         KeyValuePair._Value.isDuplicate = true;
     }
     if (KeyValuePair._Value.isDuplicate)
     {
         KeyValuePair._Value.DuplicateCount = _Value.DuplicateCount + 1;
     }
 }
        private void SwopValue(ref TagKeyValuePair Right)
        {
            RFile ret = this._Value;

            this._Value  = Right._Value;
            Right._Value = ret;
        }
        public void CommitFileNameChanges()
        {
            if (files.Length > 0)
            {
                string[] OldFolders = new string[files.Length];

                RenamerTag NewTag;
                string     NewName;

                TagTree Tree = base.BuildFileTree(true);
                while (Tree.Size > 0)
                {
                    RFile  currentFile = Tree.Pop();
                    string oldFile     = currentFile.FileName;
                    try
                    {
                        OldFolders[OldFolders.Length - Tree.Size - 1] = oldFile.Substring(0, oldFile.LastIndexOf("\\"));

                        NewTag  = currentFile.GetNewTag();
                        NewName = (currentFile.GetNewFileName(rootFolder, NewTag) + oldFile.Substring(oldFile.LastIndexOf("."))).Replace("?", "");

                        currentFile.Save(rootFolder + "\\DUPLICATES", NewName, NewTag);
                    }
                    catch (Exception ex)
                    {
                        //errors.Append(errors.Equals("") ? "General_Exception: " : "\r\n General_Exception: ");
                        //errors.Append(ex.Message);
                    }
                }
                CleanFolders(OldFolders);
            }
        }
Пример #4
0
        public TagTree BuildFileTree(bool CleanUp)
        {
            TagTree Tree = new TagTree();

            for (int i = 0; i < files.Length; i++)
            {
                RFile s = files[i];
                try
                {
                    Tree.Push(s);
                }
                catch (Exception ez)
                {
                    ExceptionHelper.ErrorFiles.Enqueue(s);
                }
                if (CleanUp)
                {
                    files[i] = null;
                }
            }
            if (CleanUp)
            {
                files = null;
            }
            return(Tree);
        }
Пример #5
0
 public RFile(RFile rhs)
 {
     isDuplicate    = rhs.isDuplicate;
     isOriginal     = rhs.isOriginal;
     DuplicateCount = rhs.DuplicateCount;
     _Corrupt       = rhs._Corrupt;
     tag            = new RenamerTag();
     tag            = rhs.tag;
 }
Пример #6
0
        public frmDetail(RFile Song)
        {
            CurrentSong = Song;

            if (CurrentSong.Tag == null && CurrentSong.Tag != null)
            {
                NewTag = CurrentSong.CopyTagFile();
            }

            InitializeComponent();
        }
        public TagKeyValuePair(ref RFile Value)
        {
            RFile temp    = Value;
            bool  corrupt = temp.Corrupt;

            if (!corrupt)
            {
                _Key = new TagKey(temp.Tag);
            }
            _Value = temp;
        }
Пример #8
0
 //Add byref
 private void AddFileRange(ref string[] FilesToAdd)
 {
     files = new RFile[FilesToAdd.Length];
     for (int i = 0; i < FilesToAdd.Length; i++)
     {
         string file    = FilesToAdd[i];
         RFile  newFile = new RFile(rootFolder, file);
         FilesToAdd[i] = null;
         files[i]      = newFile;
     }
 }
 public string[] SetPreviewFiles(int PreviewSize)
 {
     string[] newFileNames = new string[(files.Length < PreviewSize ? files.Length : PreviewSize)];
     for (int i = 0; (i < files.Length && i < PreviewSize); i++)
     {
         RFile      currentFile = Files[i];
         RenamerTag NewTag      = currentFile.GetNewTag();
         newFileNames[i] = currentFile.GetNewFileName(rootFolder, NewTag);
     }
     return(newFileNames);
 }
Пример #10
0
        private void AddFileRange(ref string[] FilesToAdd, string RegexPattern)
        {
            Regex Regex = new Regex(RegexPattern);

            for (int i = 0; i < FilesToAdd.Length; i++)
            {
                string          file = FilesToAdd[i];
                MatchCollection mc   = Regex.Matches(file);
                if (mc.Count > 0)
                {
                    RFile newFile = new RFile(rootFolder, file);
                    files[i] = newFile;
                }
            }
        }
Пример #11
0
 public void ID3RegexReplace(string SelectPattern, string newValue)
 {
     for (int i = 0; i < files.Length; i++)
     {
         RFile       currentFile = files[i];
         TagLib.File TagFile     = currentFile.Tag.File;
         TagLib.File NewTagFile  = null;
         if (TagFile.Tag != null)
         {
             TagFile.Tag.Album         = Regex.Replace(TagFile.Tag.Album, SelectPattern, newValue);
             TagFile.Tag.Performers[0] = Regex.Replace(TagFile.Tag.Performers[0], SelectPattern, newValue);
             TagFile.Tag.Title         = Regex.Replace(TagFile.Tag.Title, SelectPattern, newValue);
             NewTagFile = TagFile;
         }
         RenamerTag NewTag = new RenamerTag(NewTagFile);
         currentFile.SaveTag(NewTag);
         TagFile.Dispose();
         NewTagFile.Dispose();
     }
 }
Пример #12
0
 public TagNode(RFile Value)
 {
     _KeyValuePair = new TagKeyValuePair(ref Value);
 }