public ITaggedMediaFileInfo PreviewTagFromFileFolderName(WordCasing wordCasing) { Dictionary<string, string> fileTokens = StringUtils.Tokenize(_name, task.TagFilePattern); Dictionary<string, string> folderTokens = StringUtils.Tokenize(_folder, task.TagFolderPattern); string artist = GetTokenValue(fileTokens, folderTokens, "<A>"); string album = GetTokenValue(fileTokens, folderTokens, "<B>"); string title = GetTokenValue(fileTokens, folderTokens, "<T>"); string genre = GetTokenValue(fileTokens, folderTokens, "<G>"); string comments = GetTokenValue(fileTokens, folderTokens, "<C>"); string track = GetTokenValue(fileTokens, folderTokens, "<#>"); string year = GetTokenValue(fileTokens, folderTokens, "<Y>"); if (artist.Length > 0) _taggedFileInfo.Artist = StringUtils.Capitalize(artist, wordCasing); if (album.Length > 0) _taggedFileInfo.Album = StringUtils.Capitalize(album, wordCasing); if (title.Length > 0) _taggedFileInfo.Title = StringUtils.Capitalize(title, wordCasing); if (genre.Length > 0) _taggedFileInfo.Genre = StringUtils.Capitalize(genre, wordCasing); if (comments.Length > 0) _taggedFileInfo.Comments = StringUtils.Capitalize(comments, wordCasing); short tmp; if (track.Length > 0) { short.TryParse(track, out tmp); _taggedFileInfo.Track = tmp; } if (year.Length > 0) { short.TryParse(year, out tmp); _taggedFileInfo.Year = tmp; } return _taggedFileInfo; }
public ITaggedMediaFileInfo PreviewTagFromFileFolderName(WordCasing wordCasing) { Dictionary <string, string> fileTokens = StringUtils.Tokenize(_name, task.TagFilePattern); Dictionary <string, string> folderTokens = StringUtils.Tokenize(_folder, task.TagFolderPattern); string artist = GetTokenValue(fileTokens, folderTokens, "<A>"); string album = GetTokenValue(fileTokens, folderTokens, "<B>"); string title = GetTokenValue(fileTokens, folderTokens, "<T>"); string genre = GetTokenValue(fileTokens, folderTokens, "<G>"); string comments = GetTokenValue(fileTokens, folderTokens, "<C>"); string track = GetTokenValue(fileTokens, folderTokens, "<#>"); string year = GetTokenValue(fileTokens, folderTokens, "<Y>"); if (artist.Length > 0) { _taggedFileInfo.Artist = StringUtils.Capitalize(artist, wordCasing); } if (album.Length > 0) { _taggedFileInfo.Album = StringUtils.Capitalize(album, wordCasing); } if (title.Length > 0) { _taggedFileInfo.Title = StringUtils.Capitalize(title, wordCasing); } if (genre.Length > 0) { _taggedFileInfo.Genre = StringUtils.Capitalize(genre, wordCasing); } if (comments.Length > 0) { _taggedFileInfo.Comments = StringUtils.Capitalize(comments, wordCasing); } short tmp; if (track.Length > 0) { short.TryParse(track, out tmp); _taggedFileInfo.Track = tmp; } if (year.Length > 0) { short.TryParse(year, out tmp); _taggedFileInfo.Year = tmp; } return(_taggedFileInfo); }
public static string Capitalize(string target, WordCasing casing) { if (!string.IsNullOrEmpty(target)) { switch (casing) { case WordCasing.SentenceCase: return MakeSentenceCase(target); case WordCasing.CapitalizeWords: return CapitalizeWords(target); } } return target; }
public ITaggedMediaFileInfo PreviewUpdateTag(WordCasing wordCasing) { _taggedFileInfo.Artist = StringUtils.Capitalize(GetTagValue(task.Artist), wordCasing); _taggedFileInfo.Album = StringUtils.Capitalize(GetTagValue(task.Album), wordCasing); _taggedFileInfo.Title = StringUtils.Capitalize(GetTagValue(task.Title), wordCasing); _taggedFileInfo.Genre = StringUtils.Capitalize(GetTagValue(task.Genre), wordCasing); _taggedFileInfo.Comments = StringUtils.Capitalize(GetTagValue(task.Comments), wordCasing); short tmp; short.TryParse(GetTagValue(task.Track), out tmp); _taggedFileInfo.Track = tmp; short.TryParse(GetTagValue(task.Year), out tmp); _taggedFileInfo.Year = tmp; return(_taggedFileInfo); }
public ITaggedMediaFileInfo PreviewUpdateTag(WordCasing wordCasing) { _taggedFileInfo.Artist = StringUtils.Capitalize(GetTagValue(task.Artist), wordCasing); _taggedFileInfo.Album = StringUtils.Capitalize(GetTagValue(task.Album), wordCasing); _taggedFileInfo.Title = StringUtils.Capitalize(GetTagValue(task.Title), wordCasing); _taggedFileInfo.Genre = StringUtils.Capitalize(GetTagValue(task.Genre), wordCasing); _taggedFileInfo.Comments = StringUtils.Capitalize(GetTagValue(task.Comments), wordCasing); short tmp; short.TryParse(GetTagValue(task.Track), out tmp); _taggedFileInfo.Track = tmp; short.TryParse(GetTagValue(task.Year), out tmp); _taggedFileInfo.Year = tmp; return _taggedFileInfo; }
public static string GetFileName(WordCasing wordCasing, Track track, string renamePattern) { string newName = renamePattern; StringUtils.ReplaceToken(ref newName, "<A", track.Artist); StringUtils.ReplaceToken(ref newName, "<B", track.Album); StringUtils.ReplaceToken(ref newName, "<T", track.Title); StringUtils.ReplaceToken(ref newName, "<G", track.Genre); StringUtils.ReplaceToken(ref newName, "<#", track.Index.ToString("d2")); StringUtils.ReplaceToken(ref newName, "<Y", track.Year); newName = StringUtils.StripInvalidPathChars(newName); if (!string.IsNullOrEmpty(newName)) { return newName; } return string.Format("track{0:d2}", track.Index);; }
public static string GetFileName(WordCasing wordCasing, Track track, string renamePattern) { string newName = renamePattern; StringUtils.ReplaceToken(ref newName, "<A", track.Artist); StringUtils.ReplaceToken(ref newName, "<B", track.Album); StringUtils.ReplaceToken(ref newName, "<T", track.Title); StringUtils.ReplaceToken(ref newName, "<G", track.Genre); StringUtils.ReplaceToken(ref newName, "<#", track.Index.ToString("d2")); StringUtils.ReplaceToken(ref newName, "<Y", track.Year); newName = StringUtils.StripInvalidPathChars(newName); if (!string.IsNullOrEmpty(newName)) { return(newName); } return(string.Format("track{0:d2}", track.Index));; }
public string GetNewPath(WordCasing wordCasing) { string retVal = _taggedFileInfo.Path; if (_taggedFileInfo.IsValid) { string newName = renamePattern; bool doRename = false; FileInfo fi = _taggedFileInfo.FileSystemInfo as FileInfo; if (fi != null) { StringUtils.ReplaceToken(ref newName, "<N", fi.Name.Replace(fi.Extension, string.Empty)); StringUtils.ReplaceToken(ref newName, "<F", fi.Directory.Name); doRename = true; } if (_taggedFileInfo.HasTag) { StringUtils.ReplaceToken(ref newName, "<A", _taggedFileInfo.Artist); StringUtils.ReplaceToken(ref newName, "<B", _taggedFileInfo.Album); StringUtils.ReplaceToken(ref newName, "<T", _taggedFileInfo.Title); StringUtils.ReplaceToken(ref newName, "<G", _taggedFileInfo.Genre); StringUtils.ReplaceToken(ref newName, "<C", _taggedFileInfo.Comments); StringUtils.ReplaceToken(ref newName, "<#", _taggedFileInfo.Track.GetValueOrDefault().ToString("d2")); StringUtils.ReplaceToken(ref newName, "<Y", _taggedFileInfo.Year.GetValueOrDefault().ToString("d4")); } if (doRename) { newName = StringUtils.StripInvalidPathChars(newName); retVal = Path.Combine(fi.DirectoryName, StringUtils.Capitalize(newName, wordCasing) + fi.Extension); } } return retVal; }
public string GetNewPath(WordCasing wordCasing) { string retVal = _taggedFileInfo.Path; if (_taggedFileInfo != null && _taggedFileInfo.IsValid) { string newName = renamePattern; bool doRename = false; FileInfo fi = _taggedFileInfo.FileSystemInfo as FileInfo; if (fi != null) { StringUtils.ReplaceToken(ref newName, "<N", fi.Name.Replace(fi.Extension, string.Empty)); StringUtils.ReplaceToken(ref newName, "<F", fi.Directory.Name); doRename = true; } if (_taggedFileInfo.HasTag) { StringUtils.ReplaceToken(ref newName, "<A", _taggedFileInfo.Artist); StringUtils.ReplaceToken(ref newName, "<B", _taggedFileInfo.Album); StringUtils.ReplaceToken(ref newName, "<T", _taggedFileInfo.Title); StringUtils.ReplaceToken(ref newName, "<G", _taggedFileInfo.Genre); StringUtils.ReplaceToken(ref newName, "<C", _taggedFileInfo.Comments); StringUtils.ReplaceToken(ref newName, "<#", _taggedFileInfo.Track.GetValueOrDefault().ToString("d2")); StringUtils.ReplaceToken(ref newName, "<Y", _taggedFileInfo.Year.GetValueOrDefault().ToString("d4")); } if (doRename) { newName = StringUtils.StripInvalidPathChars(newName); retVal = Path.Combine(fi.DirectoryName, StringUtils.Capitalize(newName, wordCasing) + fi.Extension); } } return(retVal); }
public void FillTagFromFileFolderName(WordCasing wordCasing) { PreviewTagFromFileFolderName(wordCasing).Save(); }
public void UpdateTag(WordCasing wordCasing) { PreviewUpdateTag(wordCasing).Save(); }
/// <summary> /// Ctor /// </summary> /// <param name="casing"></param> /// <param name="wordSeparator"></param> public ConventionResolverStrategy(WordCasing casing, string wordSeparator) { this.WordSeparator = wordSeparator ?? String.Empty; this.Casing = casing; }
/// <summary> /// Ctor /// </summary> /// <param name="casing"></param> public ConventionResolverStrategy(WordCasing casing) : this(casing, null) { }