From 8fc4fdb849985f2f9fe185f16439f86249650788 Mon Sep 17 00:00:00 2001 From: "mikep@0113C7C3FED381A" Date: Sun, 3 Aug 2025 13:39:51 -0700 Subject: [PATCH] created-date-offset (Day-Helper-2025-08-03) P and J drives --- .vscode/launch.json | 20 +++++++++---- .vscode/tasks.json | 22 +++++++-------- ADO2025/PI6/Helper-2025-08-03.cs | 48 ++++++++++++++++++++++++++++++++ Day/HelperDay.cs | 2 ++ 4 files changed, 75 insertions(+), 17 deletions(-) create mode 100644 ADO2025/PI6/Helper-2025-08-03.cs diff --git a/.vscode/launch.json b/.vscode/launch.json index bb200f7..9bb60d1 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,19 +8,27 @@ "name": ".NET Core Launch (console)", "type": "coreclr", "request": "launch", - "preLaunchTask": "build", + "preLaunchTask": "Build", "program": "${workspaceFolder}/bin/Debug/net8.0/win-x64/File-Folder-Helper.dll", "args": [ "s", "X", - "V:/7-Question/Event 2024 Directories-xmp", + "P:/7-Question/Scanned Pictures II-a", + "Day-Helper-2025-08-03", + "*.tif", + "100", + "Years", + "P:/7-Question/Scanned Pictures II-c", + "s", + "X", + "P:/7-Question/Event 2024 Directories-xmp", "Day-Helper-2025-07-26", "L:/Git/AA/Rename/.vscode/.UserSecrets/secrets.json", "*.xmp", - "V:/7-Question/Event 2024 Directories-xmp-moved", + "P:/7-Question/Event 2024 Directories-xmp-moved", "s", "X", - "V:/1-Images-A/Images-0b793904", + "P:/1-Images-A/Images-0b793904", "Day-Helper-2024-12-17", ".job.json", "thumbs.db~sync.ffs_db~verify.json~.html", @@ -28,7 +36,7 @@ "D:/5-Other-Small/Disk/Snap2HTML/Snap2HTML.exe", "s", "X", - "V:/Tmp/Phares/Helper-2025-07-20", + "P:/Tmp/Phares/Helper-2025-07-20", "Day-Helper-2025-07-20", "871467010009.jpg", "L:/Git/AA/Rename/.vscode/.UserSecrets/secrets.json", @@ -74,7 +82,7 @@ "\"vp154\"", "s", "X", - "V:/Tmp/Phares/Pictures/2023 TI2023.6 Fall Samsung", + "P:/Tmp/Phares/Pictures/2023 TI2023.6 Fall Samsung", "Day-Helper-2025-07-05", "x-653889110721.jpg~401223300869.jpg", "3648,2736,1~3024,4032,6", diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 842e9d3..e962f49 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -43,7 +43,7 @@ "problemMatcher": "$msCompile" }, { - "label": "Format-Whitespaces", + "label": "Format Whitespaces", "command": "dotnet", "type": "process", "args": [ @@ -53,7 +53,7 @@ "problemMatcher": "$msCompile" }, { - "label": "build", + "label": "Build", "command": "dotnet", "type": "process", "args": [ @@ -67,7 +67,7 @@ "problemMatcher": "$msCompile" }, { - "label": "build Linux", + "label": "Build Linux", "command": "dotnet", "type": "process", "args": [ @@ -81,7 +81,7 @@ "problemMatcher": "$msCompile" }, { - "label": "podmanLogin", + "label": "Podman Login", "command": "podman", "type": "process", "args": [ @@ -91,7 +91,7 @@ "problemMatcher": "$msCompile" }, { - "label": "podmanBuild", + "label": "Podman Build", "command": "podman", "type": "process", "args": [ @@ -103,7 +103,7 @@ "problemMatcher": "$msCompile" }, { - "label": "podmanImageList", + "label": "Podman Image List", "command": "podman", "type": "process", "args": [ @@ -113,7 +113,7 @@ "problemMatcher": "$msCompile" }, { - "label": "podmanRun", + "label": "Podman Run", "command": "podman", "type": "process", "args": [ @@ -127,7 +127,7 @@ "problemMatcher": "$msCompile" }, { - "label": "podmanTag", + "label": "Podman Tag", "command": "podman", "type": "process", "args": [ @@ -138,7 +138,7 @@ "problemMatcher": "$msCompile" }, { - "label": "podmanPush", + "label": "Podman Push", "command": "podman", "type": "process", "args": [ @@ -148,7 +148,7 @@ "problemMatcher": "$msCompile" }, { - "label": "publish", + "label": "Publish", "command": "dotnet", "type": "process", "args": [ @@ -160,7 +160,7 @@ "problemMatcher": "$msCompile" }, { - "label": "watch", + "label": "Watch", "command": "dotnet", "type": "process", "args": [ diff --git a/ADO2025/PI6/Helper-2025-08-03.cs b/ADO2025/PI6/Helper-2025-08-03.cs new file mode 100644 index 0000000..7487426 --- /dev/null +++ b/ADO2025/PI6/Helper-2025-08-03.cs @@ -0,0 +1,48 @@ +using Microsoft.Extensions.Logging; + +namespace File_Folder_Helper.ADO2025.PI6; + +internal static partial class Helper20250803 { + + internal static void CreatedDateOffset(ILogger logger, List args) { + logger.LogInformation(args[0]); + logger.LogInformation(args[1]); + logger.LogInformation(args[2]); + logger.LogInformation(args[3]); + logger.LogInformation(args[4]); + logger.LogInformation(args[5]); + int years = int.Parse(args[3]) * -1; + if (args[4] != "Years") { + throw new NotImplementedException($"{args[4]} != Days"); + } + string checkFile; + FileInfo fileInfo; + DateTime dateTime; + string searchPattern = args[2]; + string fileNameWithoutExtension; + string fileNameWithoutExtensionOut; + string sourceDirectory = Path.GetFullPath(args[0].Split('~')[0]); + string destinationDirectory = Path.GetFullPath(args[5].Split('~')[0]); + if (!Directory.Exists(destinationDirectory)) { + _ = Directory.CreateDirectory(destinationDirectory); + } + string[] files = Directory.GetFiles(sourceDirectory, searchPattern, SearchOption.AllDirectories); + foreach (string file in files) { + fileInfo = new(file); + fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.FullName); + fileNameWithoutExtensionOut = fileNameWithoutExtension[^1] == '9' ? + $"{fileNameWithoutExtension[..^1]}7" : + fileNameWithoutExtension[^1] == '1' ? + $"{fileNameWithoutExtension[..^1]}3" : + fileNameWithoutExtension; + checkFile = Path.Combine(destinationDirectory, $"{fileNameWithoutExtensionOut}{fileInfo.Extension}"); + if (File.Exists(checkFile)) { + logger.LogWarning("<{file}> already exists!", checkFile); + continue; + } + File.Copy(file, checkFile); + dateTime = new DateTime(fileInfo.LastWriteTime.Year + years, fileInfo.LastWriteTime.Month, fileInfo.LastWriteTime.Day, fileInfo.LastWriteTime.Hour, fileInfo.LastWriteTime.Minute, fileInfo.LastWriteTime.Second); + File.SetCreationTime(checkFile, dateTime); + } + } +} \ No newline at end of file diff --git a/Day/HelperDay.cs b/Day/HelperDay.cs index 622743f..43e3b23 100644 --- a/Day/HelperDay.cs +++ b/Day/HelperDay.cs @@ -185,6 +185,8 @@ internal static class HelperDay ADO2025.PI6.Helper20250720.WriteFaceData(logger, args); else if (args[1] == "Day-Helper-2025-07-26") ADO2025.PI6.Helper20250726.CopyToCombinedEnumAndIndexFormat(logger, args); + else if (args[1] == "Day-Helper-2025-08-03") + ADO2025.PI6.Helper20250803.CreatedDateOffset(logger, args); else throw new Exception(appSettings.Company); }