public RenamerTag GetCleanTag()
        {
            RenamerTag NewTag = new RenamerTag(FileName);

            if (this._Artist == null || this._Artist.Equals(""))
            {
                NewTag._Artist = "Unknown";
            }
            if (this._Title == null || this._Title.Equals(""))
            {
                NewTag._Title = string.Format("Unknown_Track_{0:000}", Settings.UnknownCounter);
            }
            if (this._Album == null || this._Album == "")
            {
                NewTag._Album = "Unknown";
            }

            NewTag._Artist = String_Cleaner.CleanString(String_Cleaner.ChangeCase(NewTag._Artist)).Trim();
            NewTag._Album  = String_Cleaner.CleanString(String_Cleaner.ChangeCase(NewTag._Album)).Trim();
            NewTag._Title  = String_Cleaner.CleanString(String_Cleaner.ChangeCase(NewTag._Title)).Trim();
            if (Settings.RemoveComments)
            {
                NewTag._Comment = "";
            }
            return(NewTag);
        }
示例#2
0
        public TagKey(RenamerTag Tag)
        {
            string Unknown = "Unknown";

            if (Tag.Artist == null)
            {
                _Artist = ConvertString(Unknown);
            }
            else
            {
                _Artist = ConvertString(Tag.Artist);
            }
            if (Tag.Album == null)
            {
                _Album = ConvertString(Unknown);
            }
            else
            {
                _Album = ConvertString(Tag.Album);
            }
            if (Tag.Title == null)
            {
                _Title = ConvertString(Unknown);
            }
            else
            {
                _Title = ConvertString(Tag.Title);
            }

            _Track = (UInt64)Tag.Track;
        }
示例#3
0
 public RFile()
 {
     isDuplicate    = false;
     isOriginal     = false;
     _Corrupt       = false;
     DuplicateCount = 0;
     tag            = null;
 }
示例#4
0
 public void SaveTag(RenamerTag NewTag)
 {
     if (NewTag != null && !tag.Compare(NewTag))
     {
         NewTag.Save();
         tag = NewTag;
     }
 }
示例#5
0
 public RFile(RFile rhs)
 {
     isDuplicate    = rhs.isDuplicate;
     isOriginal     = rhs.isOriginal;
     DuplicateCount = rhs.DuplicateCount;
     _Corrupt       = rhs._Corrupt;
     tag            = new RenamerTag();
     tag            = rhs.tag;
 }
        public frmDetail(RFile Song)
        {
            CurrentSong = Song;

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

            InitializeComponent();
        }
 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);
 }
示例#8
0
 public RFile(string RootFolder, string Filename)
 {
     try
     {
         tag = new RenamerTag(Filename);
         if (Filename.Substring(0, Filename.LastIndexOf(".")).Equals(GetNewFileName(RootFolder, tag)))
         {
             isOriginal = true;
         }
     }
     catch (Exception)
     {
         tag      = null;
         _Corrupt = true;
     }
 }
 public bool Compare(RenamerTag NewTag)
 {
     if (this == NewTag)
     {
         return(true);
     }
     if (this._Title != NewTag._Title)
     {
         return(false);
     }
     if (this._Album != NewTag._Album)
     {
         return(false);
     }
     if (this._Track != NewTag._Track)
     {
         return(false);
     }
     if (this._Year != NewTag._Year)
     {
         return(false);
     }
     if (this._Comment != NewTag._Comment)
     {
         return(false);
     }
     if (this._Artist != NewTag._Artist)
     {
         return(false);
     }
     if (this._Genre != NewTag._Genre)
     {
         return(false);
     }
     if (this._Duration != NewTag._Duration)
     {
         return(false);
     }
     if (this._Bitrate != NewTag._Bitrate)
     {
         return(false);
     }
     return(true);
 }
 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();
     }
 }
        public void ID3RegexReplace(string SelectPattern, string newValue, Music_Tag ToUpdate)
        {
            if (Music_Tag.Empty == ToUpdate)
            {
                ID3RegexReplace(SelectPattern, newValue);
            }
            else
            {
                RFile       currentFile;
                TagLib.File TagFile;
                TagLib.File NewTagFile;
                for (int i = 0; i < files.Length; i++)
                {
                    currentFile = files[i];
                    TagFile     = currentFile.Tag.File;
                    NewTagFile  = null;
                    if (TagFile.Tag != null)
                    {
                        switch (ToUpdate)
                        {
                        case Music_Tag.Album:
                            TagFile.Tag.Album = Regex.Replace(TagFile.Tag.Album, SelectPattern, newValue);
                            break;

                        case Music_Tag.Artist:
                            TagFile.Tag.Performers[0] = Regex.Replace(TagFile.Tag.Performers[0], SelectPattern, newValue);
                            break;

                        case Music_Tag.Title:
                            TagFile.Tag.Title = Regex.Replace(TagFile.Tag.Title, SelectPattern, newValue);
                            break;
                        }
                        NewTagFile = TagFile;
                    }
                    RenamerTag NewTag = new RenamerTag(NewTagFile);
                    currentFile.SaveTag(NewTag);
                    TagFile.Dispose();
                    NewTagFile.Dispose();
                }
            }
        }
示例#12
0
        public string GetNewFileName(string RootFolder, RenamerTag Tag)
        {
            string newName = "";

            try
            {
                if (Tag != null)
                {
                    if (isDuplicate)
                    {
                        int    startIndex          = Settings.FileNamingConvention.LastIndexOf("\\");
                        int    endIndex            = Settings.FileNamingConvention.Length - startIndex;
                        string newNamingConvention = Settings.FileNamingConvention.Substring(startIndex, endIndex);

                        newName = newNamingConvention.Replace(Settings.Artist, Tag.Artist)
                                  .Replace(Settings.Title, Tag.Title)
                                  .Replace(Settings.Album, Tag.Album)
                                  .Replace(Settings.Track, Convert.ToString(Tag.Track));

                        newName = RootFolder + "\\DUPLICATES" + newName + "_" + DuplicateCount;
                    }
                    else
                    {
                        string name = Settings.FileNamingConvention.Replace(Settings.Artist, Tag.Artist)
                                      .Replace(Settings.Title, Tag.Title).Replace(Settings.Album, Tag.Album)
                                      .Replace(Settings.Track, Convert.ToString(Tag.Track));
                        newName = RootFolder + name;
                    }
                }
            }
            catch (Exception)
            {
                int ErrorStartIndex = FileName.LastIndexOf("\\") + 1;
                int ErrorEndIndex   = FileName.LastIndexOf(".") - ErrorStartIndex;
                newName = RootFolder + @"\0_FAILED\" + FileName.Substring(ErrorStartIndex, ErrorEndIndex);
            }
            return(newName);
        }
示例#13
0
 public static bool CompareTags(RenamerTag left, RenamerTag right)
 {
     return(left.Compare(right));
 }
示例#14
0
 public bool CompareTags(RenamerTag NewTag)
 {
     return(Tag.Compare(NewTag));
 }
示例#15
0
 public void Save(string RemoveFolder, string NewName, RenamerTag NewTag)
 {
     SaveTag(NewTag);
     SaveFile(NewName, RemoveFolder);
 }