diff --git a/NAPS2.Console/AutomatedScanning.cs b/NAPS2.Console/AutomatedScanning.cs index 324db89f4..01031fd55 100644 --- a/NAPS2.Console/AutomatedScanning.cs +++ b/NAPS2.Console/AutomatedScanning.cs @@ -149,7 +149,7 @@ namespace NAPS2.Console && File.Exists(subPath) && !options.ForceOverwrite) { - errorOutput.DisplayError(string.Format(ConsoleResources.FileAlreadyExists, Path.GetFileName(subPath))); + errorOutput.DisplayError(string.Format(ConsoleResources.FileAlreadyExists, Path.GetFullPath(subPath))); return false; } return true; @@ -311,24 +311,29 @@ namespace NAPS2.Console private void ExportToImageFiles() { - // TODO: Maybe add return code + var path = fileNameSubstitution.SubstituteFileName(options.OutputPath, startTime); DoExportToImageFiles(options.OutputPath); - - OutputVerbose(ConsoleResources.FinishedSavingImages, options.OutputPath); + OutputVerbose(ConsoleResources.FinishedSavingImages, Path.GetFullPath(path)); } private void DoExportToImageFiles(string outputPath) { // TODO: If I add new image settings this may break things imageSettingsContainer.ImageSettings = new ImageSettings { JpegQuality = options.JpegQuality }; - imageSaver.SaveImages(outputPath, startTime, scannedImages); + imageSaver.SaveImages(outputPath, startTime, scannedImages, i => + { + OutputVerbose(ConsoleResources.ExportingImage, i, scannedImages.Count); + return true; + }); } private void ExportToPdf() { + // Get a local copy of the path just for output + var path = fileNameSubstitution.SubstituteFileName(options.OutputPath, startTime); if (DoExportToPdf(options.OutputPath)) { - OutputVerbose(ConsoleResources.SuccessfullySavedPdf, options.OutputPath); + OutputVerbose(ConsoleResources.SuccessfullySavedPdf, path); } } @@ -378,7 +383,7 @@ namespace NAPS2.Console return pdfSaver.SavePdf(path, startTime, scannedImages, pdfSettings, ocrLanguageCode, i => { - OutputVerbose(ConsoleResources.ExportedPage, i, scannedImages.Count); + OutputVerbose(ConsoleResources.ExportingPage, i, scannedImages.Count); return true; }); } diff --git a/NAPS2.Console/Lang/Resources/ConsoleResources.Designer.cs b/NAPS2.Console/Lang/Resources/ConsoleResources.Designer.cs index ff8bfa45b..178a6dee4 100644 --- a/NAPS2.Console/Lang/Resources/ConsoleResources.Designer.cs +++ b/NAPS2.Console/Lang/Resources/ConsoleResources.Designer.cs @@ -159,15 +159,6 @@ namespace NAPS2.Console.Lang.Resources { } } - /// - /// Looks up a localized string similar to Exported page {0} of {1}.. - /// - internal static string ExportedPage { - get { - return ResourceManager.GetString("ExportedPage", resourceCulture); - } - } - /// /// Looks up a localized string similar to Exporting.... /// @@ -177,6 +168,15 @@ namespace NAPS2.Console.Lang.Resources { } } + /// + /// Looks up a localized string similar to Exporting image {0} of {1}.... + /// + internal static string ExportingImage { + get { + return ResourceManager.GetString("ExportingImage", resourceCulture); + } + } + /// /// Looks up a localized string similar to Exporting images for use as an attachment.... /// @@ -186,6 +186,15 @@ namespace NAPS2.Console.Lang.Resources { } } + /// + /// Looks up a localized string similar to Exporting page {0} of {1}.. + /// + internal static string ExportingPage { + get { + return ResourceManager.GetString("ExportingPage", resourceCulture); + } + } + /// /// Looks up a localized string similar to Exporting PDF for use as an attachment.... /// diff --git a/NAPS2.Console/Lang/Resources/ConsoleResources.resx b/NAPS2.Console/Lang/Resources/ConsoleResources.resx index 5afb5e0b1..c049c4c95 100644 --- a/NAPS2.Console/Lang/Resources/ConsoleResources.resx +++ b/NAPS2.Console/Lang/Resources/ConsoleResources.resx @@ -132,8 +132,8 @@ Scanned Image - - Exported page {0} of {1}. + + Exporting page {0} of {1}. Successfully saved PDF file to {0} @@ -223,4 +223,7 @@ Use the "--importpassword" option. An error occurred when trying to save the file. + + Exporting image {0} of {1}... + \ No newline at end of file diff --git a/NAPS2.Core/ImportExport/Images/ImageSaver.cs b/NAPS2.Core/ImportExport/Images/ImageSaver.cs index a07d24455..acfcc3e9e 100644 --- a/NAPS2.Core/ImportExport/Images/ImageSaver.cs +++ b/NAPS2.Core/ImportExport/Images/ImageSaver.cs @@ -52,8 +52,9 @@ namespace NAPS2.ImportExport.Images /// If multiple images are provided, they will be saved to files with numeric identifiers, e.g. img1.jpg, img2.jpg, etc.. /// /// The name of the file to save. For multiple images, this is modified by appending a number before the extension. + /// /// The collection of images to save. - public void SaveImages(string fileName, DateTime dateTime, ICollection images) + public void SaveImages(string fileName, DateTime dateTime, ICollection images, Func progressCallback) { try { @@ -78,10 +79,14 @@ namespace NAPS2.ImportExport.Images return; } - int i = 0; + int i = 1; int digits = (int)Math.Floor(Math.Log10(images.Count)) + 1; foreach (IScannedImage img in images) { + if (!progressCallback(i)) + { + return; + } if (images.Count == 1 && File.Exists(subFileName)) { var dialogResult = overwritePrompt.ConfirmOverwrite(subFileName); @@ -102,10 +107,11 @@ namespace NAPS2.ImportExport.Images } else { - var fileNameN = fileNameSubstitution.SubstituteFileName(fileName, dateTime, true, i++, digits); + var fileNameN = fileNameSubstitution.SubstituteFileName(fileName, dateTime, true, i - 1, digits); DoSaveImage(baseImage, fileNameN, format); } } + i++; } } catch (UnauthorizedAccessException) diff --git a/NAPS2.Core/WinForms/FDesktop.cs b/NAPS2.Core/WinForms/FDesktop.cs index 856cc33b9..1896aea2b 100644 --- a/NAPS2.Core/WinForms/FDesktop.cs +++ b/NAPS2.Core/WinForms/FDesktop.cs @@ -610,7 +610,7 @@ namespace NAPS2.WinForms { UserConfigManager.Config.LastImageExt = (Path.GetExtension(sd.FileName) ?? "").Replace(".", ""); UserConfigManager.Save(); - imageSaver.SaveImages(sd.FileName, DateTime.Now, images); + imageSaver.SaveImages(sd.FileName, DateTime.Now, images, i => true); changeTracker.HasUnsavedChanges = false; } }