EAF CopyDirectories
This commit is contained in:
parent
2aa9c0f018
commit
966eb653be
13
.vscode/launch.json
vendored
13
.vscode/launch.json
vendored
@ -13,12 +13,13 @@
|
|||||||
"args": [
|
"args": [
|
||||||
"s",
|
"s",
|
||||||
"X",
|
"X",
|
||||||
"L:/Git/Notes-Network/.Network/.vscode/helper",
|
"\\\\mesfs.infineon.com\\EC_Characterization_Si\\Dummy",
|
||||||
"Day-Helper-2024-07-18",
|
"Day-Helper-2024-07-24",
|
||||||
"hosts.jsonl",
|
"*Staging*v2*56*0*",
|
||||||
"Network",
|
"Staging__v2_56_0__",
|
||||||
"Wired",
|
"Production__v2_56_0__",
|
||||||
".md",
|
"5555",
|
||||||
|
"6666",
|
||||||
"7777",
|
"7777",
|
||||||
"8888",
|
"8888",
|
||||||
"9999"
|
"9999"
|
||||||
|
38
Day/2024-Q3/Helper-2024-07-24.cs
Normal file
38
Day/2024-Q3/Helper-2024-07-24.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace File_Folder_Helper.Day;
|
||||||
|
|
||||||
|
internal static partial class Helper20240724
|
||||||
|
{
|
||||||
|
|
||||||
|
internal static void CopyDirectories(ILogger<Worker> logger, List<string> args)
|
||||||
|
{
|
||||||
|
string[] files;
|
||||||
|
Process process;
|
||||||
|
string checkDirectory;
|
||||||
|
string filter = args[3];
|
||||||
|
string replaceWith = args[4];
|
||||||
|
string searchPattern = args[2];
|
||||||
|
string sourceDirectory = Path.GetFullPath(args[0]);
|
||||||
|
string[] foundDirectories = Directory.GetDirectories(sourceDirectory, searchPattern, SearchOption.AllDirectories);
|
||||||
|
logger.LogInformation($"Found {foundDirectories.Length} directories");
|
||||||
|
foreach (string foundDirectory in foundDirectories)
|
||||||
|
{
|
||||||
|
if (!foundDirectory.Contains(filter))
|
||||||
|
continue;
|
||||||
|
logger.LogDebug(foundDirectory);
|
||||||
|
checkDirectory = foundDirectory.Replace(filter, replaceWith);
|
||||||
|
if (Directory.Exists(checkDirectory))
|
||||||
|
{
|
||||||
|
files = Directory.GetFiles(checkDirectory, "*", SearchOption.AllDirectories);
|
||||||
|
if (files.Length > 0)
|
||||||
|
continue;
|
||||||
|
Directory.Delete(checkDirectory);
|
||||||
|
}
|
||||||
|
process = Process.Start("cmd.exe", $"/c xCopy \"{foundDirectory}\" \"{checkDirectory}\" /S /E /I /H /Y");
|
||||||
|
process.WaitForExit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -81,6 +81,8 @@ internal static class HelperDay
|
|||||||
Day.Helper20240711.GitRemoteRemove(logger, args);
|
Day.Helper20240711.GitRemoteRemove(logger, args);
|
||||||
else if (args[1] == "Day-Helper-2024-07-18")
|
else if (args[1] == "Day-Helper-2024-07-18")
|
||||||
Day.Helper20240718.JsonToMarkdown(logger, args);
|
Day.Helper20240718.JsonToMarkdown(logger, args);
|
||||||
|
else if (args[1] == "Day-Helper-2024-07-24")
|
||||||
|
Day.Helper20240724.CopyDirectories(logger, args);
|
||||||
else
|
else
|
||||||
throw new Exception(appSettings.Company);
|
throw new Exception(appSettings.Company);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user