Exemplo n.º 1
0
        static void Main(string[] args)
        {
            if (args.Count() == 3)
            {
                string source        = args[0];
                string dest          = args[1];
                string searchPattern = args[2];

                FileInfo[] fi = PicSortTools.ListAllPictures(source, searchPattern, true);
                System.Console.WriteLine(string.Format("{0} fichiers {1} dans {2}", fi.Count(), searchPattern, source));
                int i = 0;
                foreach (FileInfo f in fi)
                {
                    PicSortTools.MovePicture(f, dest, false);
                    System.Console.WriteLine(string.Format("{0}/{1} - {2} a été traité", ++i, fi.Count(), f.Name));
                }
            }
            else
            {
                System.Console.WriteLine("PicSortConsole.exe source destination searchPattern");
                System.Console.WriteLine("   source : Represents the fully qualified path of the source directory");
                System.Console.WriteLine("   destination : Represents the fully qualified path of the destination directory");
                System.Console.WriteLine("   searchPattern : Contains a combination of valid literal path and wildcard (* and ?) characters");
            }
        }
Exemplo n.º 2
0
        public void Test_MovePicture()
        {
            // Because the file copied in the test folder have the current date as modification date
            string dateFolder = string.Format("PicSort_{0}_{1}", DateTime.Now.Year, DateTime.Now.Month.ToString("D2"));

            // The file already exists in the destination folder
            FileInfo fiDesert = new FileInfo(@".\MovePicture\Desert.jpg");

            PicSortTools.MovePicture(fiDesert, @".\ResultsPictures", false);

            Assert.IsFalse(File.Exists(@".\MovePicture\Desert.jpg"));
            Assert.IsTrue(File.Exists(string.Format(@".\ResultsPictures\{0}\Desert.jpg", dateFolder)));

            // The file does not exists in the destination folder
            FileInfo fiKoala = new FileInfo(@".\MovePicture\Koala.jpg");

            PicSortTools.MovePicture(fiKoala, @".\ResultsPictures", false);

            Assert.IsFalse(File.Exists(@".\MovePicture\Koala.jpg"));
            Assert.IsTrue(File.Exists(string.Format(@".\ResultsPictures\{0}\Koala.jpg", dateFolder)));

            FileInfo fiPenguins = new FileInfo(@".\MovePicture\Penguins.jpg");

            PicSortTools.MovePicture(fiPenguins, @".\ResultsPictures", false);

            Assert.IsFalse(File.Exists(@".\MovePicture\Penguins.jpg"));
            Assert.IsTrue(File.Exists(string.Format(@".\ResultsPictures\{0}\Penguins.jpg", dateFolder)));
        }
Exemplo n.º 3
0
        public void Test_ListAllPictures()
        {
            FileInfo [] fi = PicSortTools.ListAllPictures(@".\ListAllPictures", "*.jpg", true);
            // There are 3 jpg pictures in the folder
            Assert.IsTrue(fi.Length == 3);

            fi = PicSortTools.ListAllPictures(@".\ListAllPictures", "*.png", true);
            Assert.IsTrue(fi.Length == 2);
        }
Exemplo n.º 4
0
        public void Test_MovePicture_DesertJpg_To_2008_03()
        {
            // The file already exists in the destination folder
            FileInfo fiDesert   = new FileInfo(@".\MovePicture\Desert.jpg");
            string   dateFolder = string.Format("PicSort_{0}_{1}", 2008, "03");

            PicSortTools.MovePicture(fiDesert, @".\ResultsPictures", false);

            Assert.IsFalse(File.Exists(@".\MovePicture\Desert.jpg"));
            Assert.IsTrue(File.Exists(string.Format(@".\ResultsPictures\{0}\Desert.jpg", dateFolder)));
        }
Exemplo n.º 5
0
        public void Test_MovePicture_PngWithoutDateTaken_To_ActualDate()
        {
            var dateFolder = string.Format("PicSort_{0}_{1}", DateTime.Now.Year, DateTime.Now.Month.ToString("D2"));

            string   fileName = "TigerWithoutDateTaken.png";
            FileInfo fiTigerWithoutDateTaken = new FileInfo($@".\MovePicture\{fileName}");

            PicSortTools.MovePicture(fiTigerWithoutDateTaken, @".\ResultsPictures", false);

            Assert.IsFalse(File.Exists($@".\MovePicture\{fileName}"));
            Assert.IsTrue(File.Exists(string.Format(@".\ResultsPictures\{0}\{1}", dateFolder, fileName)));
        }
Exemplo n.º 6
0
        public void Test_MovePicture_TigerPng_To_2008_02()
        {
            var dateFolder = string.Format("PicSort_{0}_{1}", 2008, "02");
            var fileName   = "Tiger.png";

            FileInfo fiTiger = new FileInfo($@".\MovePicture\{fileName}");

            PicSortTools.MovePicture(fiTiger, @".\ResultsPictures", false);

            Assert.IsFalse(File.Exists($@".\MovePicture\{fileName}"));
            Assert.IsTrue(File.Exists(string.Format(@".\ResultsPictures\{0}\{1}", dateFolder, fileName)));
        }
Exemplo n.º 7
0
        public void Test_MovePicture_KoalaAndPenguinsJpg_To_2008_02()
        {
            // The file does not exists in the destination folder
            FileInfo fiKoala = new FileInfo(@".\MovePicture\Koala.jpg");

            PicSortTools.MovePicture(fiKoala, @".\ResultsPictures", false);

            Assert.IsFalse(File.Exists(@".\MovePicture\Koala.jpg"));
            var dateFolder = string.Format("PicSort_{0}_{1}", 2008, "02");

            Assert.IsTrue(File.Exists(string.Format(@".\ResultsPictures\{0}\Koala.jpg", dateFolder)));

            FileInfo fiPenguins = new FileInfo(@".\MovePicture\Penguins.jpg");

            PicSortTools.MovePicture(fiPenguins, @".\ResultsPictures", false);

            Assert.IsFalse(File.Exists(@".\MovePicture\Penguins.jpg"));
            Assert.IsTrue(File.Exists(string.Format(@".\ResultsPictures\{0}\Penguins.jpg", dateFolder)));
        }