Exemple #1
0
        private static void ElaborateWhatsAppFile(string workingPath, ExFile file, bool dryRun)
        {
            Console.WriteLine("WhatsApp file");
            var whatsAppDirectory = CreateWhatsAppDirectoryFor(file, dryRun);

            Move(workingPath, file, whatsAppDirectory, dryRun);
            Console.WriteLine();
        }
Exemple #2
0
        private static void Move(string workingPath, ExFile file, string whatsAppDirectory, bool dryRun)
        {
            var destFileName = Path.Join(whatsAppDirectory, file.FileInfo.Name);

            Console.WriteLine($"{file.FileInfo.FullName.RelativeTo(workingPath)} => {destFileName.RelativeTo(workingPath)}");

            if (!dryRun)
            {
                File.Move(file.FileInfo.FullName, destFileName);
            }
        }
Exemple #3
0
        private static void ElaboratePictureFile(string workingPath, ExFile file, bool dryRun)
        {
            var takenAt         = file.TakenAt().Value;
            var pictureFilesDir = CreateDirectory(file.FileInfo.DirectoryName, Pictures, dryRun);
            var yearDir         = CreateDirectory(pictureFilesDir, takenAt.Year.ToString(), dryRun);
            var monthDir        = CreateDirectory(yearDir, $"{takenAt.Month:00}", dryRun);
            var dateDir         = CreateDirectory(monthDir, $"{takenAt.Year:0000}-{takenAt.Month:00}-{takenAt.Day:00}", dryRun);

            Console.WriteLine($"{file.FileInfo.FullName.RelativeTo(workingPath)} => {DirectoryExtensions.RelativeTo(dateDir, workingPath)}");
            var destFileName = Path.Join(dateDir, file.FileInfo.Name);

            if (!dryRun)
            {
                File.Move(file.FileInfo.FullName, destFileName);
                File.SetCreationTime(destFileName, takenAt);
                File.SetLastWriteTime(destFileName, takenAt);
                File.SetLastAccessTime(destFileName, takenAt);
            }
        }
 internal static ExifDateTime TakenAt(this ExFile file) =>
 file.ImageFile.Properties.Get <ExifDateTime>(ExifTag.DateTimeDigitized);
Exemple #5
0
 private static string CreateWhatsAppDirectoryFor(ExFile file, bool dryRun) =>
 CreateDirectory(file.FileInfo.DirectoryName, Whatsapp, dryRun);