Geeks With Blogs

@woodbasen
  • woodbasen Man må bare elske Fars dag! ungerne laver morgenmad. En gave der garanterer en perfekt @COPENHELL. En halv arbejdsdag og en fodboldkamp :-D about 469 days ago

Woodbase Umbraco - CSS - jQuery - .Net - C#

If you have an IPhone, you probably know that the name in the playlist comes from the “Title”-attribute instead of the filename. Usually that is not a problem.

But when I plug my IPhone to the car stereo the tracks are sorted alphabetically by the “title”-attribute. That becomes a problem when You have an e-book where each chapter starts with “Track 01”.

You can manually update this in the file properties (from the context menu in Windows Explorer), but doing so for +200 tracks – no thank you :)

The FileInfo-class does not contain a property for this special audio file attribute. However the problem is easily solved using TagLib.

The method below, not optimized in any way - just solving the problem at hand, will set the “title”-attribute to the file name.

private static void UpdateTitleAttr(string dirPath, string fileFilter)
        {
            var files = System.IO.Directory.GetFiles(dirPath, fileFilter);
           
            foreach (var file in files)
            {
                var f = TagLib.File.Create(file);
                var newTitle = f.Name.Substring(f.Name.LastIndexOf(@"\") + 1);
                f.Tag.Title = newTitle;
                f.Save();   
            }
        }

So now I can hear e-books while driving :P

Posted on Friday, June 8, 2012 9:40 AM | Back to top


Comments on this post: IPhone track title

No comments posted yet.
Your comment:
 (will show your gravatar)
 


Copyright © woodbase | Powered by: GeeksWithBlogs.net | Join free