From a47e881432ec6dc2aabad036b9924078e7d8d8f3 Mon Sep 17 00:00:00 2001 From: Marco Giuntoni Date: Thu, 16 May 2024 17:53:27 +0200 Subject: [PATCH] Added option to copy all non compressed files Added support for BMP files --- Program.cs | 23 ++++++++++++++++++++++- Properties/launchSettings.json | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Program.cs b/Program.cs index a93b0b9..3b6c364 100644 --- a/Program.cs +++ b/Program.cs @@ -68,6 +68,10 @@ namespace ComicCompressor [Option("-j|--image", Description = "process images only")] public bool DoImage { get; } = false; + + [Option("-a|--copyall", Description = "copy all unprocessed files")] + public bool DoCopyAll { get; } = false; + #endregion #region STATISTICS @@ -206,6 +210,7 @@ namespace ComicCompressor var relativePath = Path.GetRelativePath(Input, filename); var outputPath = Path.Join(OutputFolder, Path.ChangeExtension(relativePath, "cbz")); var outputPath_webp = Path.Join(OutputFolder, Path.ChangeExtension(relativePath, "webp")); + var outputPath_same = Path.Join(OutputFolder, relativePath); int digits = 1+(int)Math.Floor(Math.Log((Double)total) / Math.Log(10.0)); string print_line_header = ""; @@ -288,6 +293,7 @@ namespace ComicCompressor filename.ToLower().EndsWith("jpg") || filename.ToLower().EndsWith("jpeg") || filename.ToLower().EndsWith("tif") || + filename.ToLower().EndsWith("bmp") || filename.ToLower().EndsWith("png")) { outputPath = Path.Join(OutputFolder, Path.ChangeExtension(relativePath, "webp")); @@ -316,7 +322,22 @@ namespace ComicCompressor if (!filename.ToLower().EndsWith(".cbr") && !filename.ToLower().EndsWith(".cbz")) { - Logger.Log(relativePath, LogLevel.Verbose, true, Color.LightYellow); + // COPY FILE + if(DoCopyAll) + { + + Directory.CreateDirectory(Path.GetDirectoryName(outputPath_same)); + + if (File.Exists(outputPath_same)) + Logger.Log(outputPath_same, LogLevel.Verbose, true, Color.LightYellow); + else + { + File.Copy(filename, outputPath_same, true); + Logger.Log(outputPath_same, LogLevel.Verbose, true, Color.Orange); + } + } + else + Logger.Log(outputPath_same, LogLevel.Verbose, true, Color.LightYellow); return; } diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json index d1a7267..2272243 100644 --- a/Properties/launchSettings.json +++ b/Properties/launchSettings.json @@ -18,7 +18,7 @@ }, "ComicCompress": { "commandName": "Project", - "commandLineArgs": "-i _IMG_ -o _IMG_WEBP_ -r -s " + "commandLineArgs": "-i _IMG_ -o _IMG_WEBP_ -r -s -d -a" } } } \ No newline at end of file