Ejemplo n.º 1
0
        //---------------------------------------------------------------------------------------------

        private static void RenameTrackAndAddToList(
            ITrackFile track,
            int trackNumber,
            List <RenamedTrackFile> renamedTracks,
            int artistNameMaxLength,
            int albumNameMaxLength)
        {
            var newArtistName = $"{track.Artist.Replace(" ", "")}";
            var newAlbum      = $"{track.Album.Replace(" ", "")}";

            if (newArtistName.Length > artistNameMaxLength)
            {
                newArtistName = newArtistName.Substring(0, artistNameMaxLength);
            }

            if (newAlbum.Length > albumNameMaxLength)
            {
                newAlbum = newAlbum.Substring(0, albumNameMaxLength);
            }

            string newName;

            while (true)
            {
                newName = $"{newArtistName}_{newAlbum}_{trackNumber:00}{track.FileExtension}";

                bool nameAlreadyExists =
                    renamedTracks.Exists(rt => rt.NewFilename.Equals(newName, StringComparison.OrdinalIgnoreCase));

                if (nameAlreadyExists)
                {
                    trackNumber++;
                    continue;
                }

                break;
            }

            renamedTracks.Add(new RenamedTrackFile(track, newName));
        }
Ejemplo n.º 2
0
        //---------------------------------------------------------------------------------------------

        public RenamedTrackFile(ITrackFile trackFile, string newFilename)
        {
            File        = trackFile;
            NewFilename = newFilename;
        }