match-directory
This commit is contained in:
parent
43527b3356
commit
846908d3f4
6
.vscode/launch.json
vendored
6
.vscode/launch.json
vendored
@ -11,6 +11,12 @@
|
||||
"preLaunchTask": "build",
|
||||
"program": "${workspaceFolder}/bin/Debug/net8.0/win-x64/File-Folder-Helper.dll",
|
||||
"args": [
|
||||
"s",
|
||||
"X",
|
||||
"D:/5-Other-Small/Proxmox/ffnm",
|
||||
"Day-Helper-2025-05-21",
|
||||
"*.pdf",
|
||||
"*.md",
|
||||
"s",
|
||||
"X",
|
||||
"D:/Tmp/phares/VisualStudioCode",
|
||||
|
35
ADO2025/PI6/Helper-2025-05-21.cs
Normal file
35
ADO2025/PI6/Helper-2025-05-21.cs
Normal file
@ -0,0 +1,35 @@
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace File_Folder_Helper.ADO2025.PI6;
|
||||
|
||||
internal static partial class Helper20250521 {
|
||||
|
||||
private record Record(string Directory, string FileNameWithoutExtension);
|
||||
|
||||
internal static void MatchDirectory(ILogger<Worker> logger, List<string> args) {
|
||||
Record record;
|
||||
string[] files;
|
||||
string checkFile;
|
||||
string searchPattern = args[2];
|
||||
string fileNameWithoutExtension;
|
||||
string searchPatternB = args[3];
|
||||
Dictionary<string, string> keyValuePairs = [];
|
||||
string sourceDirectory = Path.GetFullPath(args[0].Split('~')[0]);
|
||||
files = Directory.GetFiles(sourceDirectory, searchPattern, SearchOption.AllDirectories);
|
||||
foreach (string file in files) {
|
||||
keyValuePairs.Add(Path.GetFileNameWithoutExtension(file), Path.GetDirectoryName(file));
|
||||
}
|
||||
files = Directory.GetFiles(sourceDirectory, searchPatternB, SearchOption.AllDirectories);
|
||||
foreach (string file in files) {
|
||||
fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file);
|
||||
if (!keyValuePairs.TryGetValue(fileNameWithoutExtension, out string? match))
|
||||
continue;
|
||||
checkFile = Path.Combine(match, Path.GetFileName(file));
|
||||
if (File.Exists(checkFile))
|
||||
continue;
|
||||
File.Move(file, checkFile);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -163,6 +163,8 @@ internal static class HelperDay
|
||||
ADO2025.PI5.Helper20250505.HyperTextMarkupLanguageToPortableDocumentFormat(logger, args);
|
||||
else if (args[1] == "Day-Helper-2025-05-19")
|
||||
ADO2025.PI6.Helper20250519.LiveSync(logger, args);
|
||||
else if (args[1] == "Day-Helper-2025-05-21")
|
||||
ADO2025.PI6.Helper20250521.MatchDirectory(logger, args);
|
||||
else
|
||||
throw new Exception(appSettings.Company);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user