public override OperationResult <string> Process(DirectoryInfo directory) { var result = new OperationResult <string>(); var data = string.Empty; var found = 0; var modified = 0; var metaDatasForFilesInFolder = GetAudioMetaDatasForDirectory(directory); if (metaDatasForFilesInFolder.Any()) { found = metaDatasForFilesInFolder.Count(); var firstMetaData = metaDatasForFilesInFolder.OrderBy(x => x.TrackNumber).First(); var release = firstMetaData.Release; foreach (var metaData in metaDatasForFilesInFolder.Where(x => x.Release != release)) { modified++; Console.WriteLine($"╟ Setting Release to [{ release }], was [{ metaData.Release }] on file [{ metaData.FileInfo.Name}"); metaData.Release = release; if (!Configuration.Inspector.IsInReadOnlyMode) { TagsHelper.WriteTags(metaData, metaData.Filename); } } data = $"Found [{ found }] files, Modified [{ modified }] files"; } result.Data = data; result.IsSuccess = true; return(result); }
public override OperationResult <string> Process(DirectoryInfo directory) { var result = new OperationResult <string>(); var data = string.Empty; var found = 0; var modified = 0; var metaDatasForFilesInFolder = GetAudioMetaDatasForDirectory(directory); if (metaDatasForFilesInFolder.Any()) { found = metaDatasForFilesInFolder.Count(); var firstMetaData = metaDatasForFilesInFolder.OrderBy(x => x.Filename ?? string.Empty) .ThenBy(x => SafeParser.ToNumber <short>(x.TrackNumber)).FirstOrDefault(); if (firstMetaData == null) { return new OperationResult <string>("Error Getting First MetaData") { Data = $"Unable to read Metadatas for Directory [{directory.FullName}]" } } ; var artist = firstMetaData.Artist; foreach (var metaData in metaDatasForFilesInFolder.Where(x => x.Artist != artist)) { modified++; Console.WriteLine( $"╟ Setting Artist to [{artist}], was [{metaData.Artist}] on file [{metaData.FileInfo.Name}"); metaData.Artist = artist; if (!Configuration.Inspector.IsInReadOnlyMode) { TagsHelper.WriteTags(metaData, metaData.Filename); } } data = $"Found [{found}] files, Modified [{modified}] files"; } result.Data = data; result.IsSuccess = true; return(result); } }