Update Namespaces
This commit is contained in:
37
Day/Q42023/Helper-2023-11-08.cs
Normal file
37
Day/Q42023/Helper-2023-11-08.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace File_Folder_Helper.Day.Q42023;
|
||||
|
||||
internal static class Helper20231108
|
||||
{
|
||||
|
||||
internal static void MasterImage(ILogger<Worker> logger, List<string> args)
|
||||
{
|
||||
string fileName;
|
||||
string checkFile;
|
||||
string[] aSegments;
|
||||
string[] bSegments;
|
||||
if (!Directory.Exists(args[0]))
|
||||
throw new Exception(args[0]);
|
||||
if (!Directory.Exists(args[2]))
|
||||
throw new Exception(args[2]);
|
||||
string directoryName = Path.GetFileName(args[0]) ?? throw new Exception();
|
||||
string[] files = Directory.GetFiles(args[0]);
|
||||
logger.LogInformation("{fileCount}", files.Length.ToString());
|
||||
foreach (string file in files)
|
||||
{
|
||||
aSegments = Path.GetFileNameWithoutExtension(file).Split('-');
|
||||
if (aSegments.Length != 2)
|
||||
continue;
|
||||
bSegments = aSegments[1].Split('_');
|
||||
if (bSegments.Length != 3)
|
||||
continue;
|
||||
fileName = $"{directoryName}-{bSegments[1]}-{bSegments[0]}{Path.GetExtension(file)}";
|
||||
checkFile = Path.Combine(args[2], fileName);
|
||||
if (File.Exists(checkFile))
|
||||
continue;
|
||||
File.Copy(file, checkFile);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user