public Placement(SongInformation songInformation)
        {
            this.songInformation = songInformation;

            if (songInformation.IsCompilation)
            {
                if (null == songInformation.Album)
                {
                    this.parentDirs = new string[] { "Compilations" };
                }
                else
                {
                    this.parentDirs = new string[] { "Compilations", songInformation.Album };
                }
            }
            else
            {
                if (null == songInformation.Artist)
                {
                    if (null == songInformation.Album)
                    {
                        this.parentDirs = new string[0];
                    }
                    else
                    {
                        this.parentDirs = new string[] { songInformation.Album };
                    }
                }
                else
                {
                    if (null == songInformation.Album)
                    {
                        this.parentDirs = new string[] { songInformation.Artist };
                    }
                    else
                    {
                        this.parentDirs = new string[] { songInformation.Artist, songInformation.Album };
                    }
                }
            }

            if (null == songInformation.Title)
            {
                this.filename = Path.GetFileName(songInformation.Path);
            }
            else if (null == songInformation.Track)
            {
                this.filename = songInformation.Title + Path.GetExtension(songInformation.Path);
            }
            else
            {
                this.filename = string.Format(
                    "{0} - {1}{2}",
                    songInformation.Track.Value.ToString("D2"),
                    songInformation.Title,
                    Path.GetExtension(songInformation.Path));
            }
        }
Beispiel #2
0
        public static void Main(string[] args)
        {
            if (2 != args.Length)
            {
                Console.WriteLine("RenameAndMoveMusic [source directory] [destination directory]");
                return;
            }

            var sourceDir = args[0].Normalize();
            var destinationDir = args[1].Normalize();

            try
            {
                foreach (var path in Program.GetAllMP3AndM4AFiles(sourceDir))
                {
                    try
                    {
                        var songInformation = new SongInformation(path);

                        /*Console.WriteLine(
            @"{0}
            Album: {1}
            Artist: {2}
            Title: {3}
            Track: {4}
            IsCompilation: {5}",
                            path,
                            songInformation.Album,
                            songInformation.Artist,
                            songInformation.Title,
                            songInformation.Track,
                            songInformation.IsCompilation);*/

                        var placement = new Placement(songInformation);

                        /*foreach (var dir in placement.ParentDirs)
                            Console.WriteLine("\t\t" + dir);

                        Console.WriteLine("\t\t" + placement.Filename);*/

                        Program.Move(destinationDir, path, placement);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Problem with " + path);
                        var ex = e;

                        do
                        {
                            Console.WriteLine(ex);
                            ex = ex.InnerException;
                        } while (null != ex);
                    }
                }

                Program.Clean(destinationDir);
            }
            catch (Exception e)
            {
                var ex = e;

                do
                {
                    Console.WriteLine(ex);
                    ex = ex.InnerException;
                } while (null != ex);
            }
        }