Zip only went 1000 days...
Added Create Note Files Changed to Path.Combine
This commit is contained in:
parent
0987ee8b80
commit
81472165f7
41
Helpers/HelperCreateNoteFiles.cs
Normal file
41
Helpers/HelperCreateNoteFiles.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using System.Globalization;
|
||||
|
||||
namespace File_Folder_Helper.Helpers;
|
||||
|
||||
internal static class HelperCreateNoteFiles
|
||||
{
|
||||
|
||||
internal static void CreateNoteFiles(string argsZero)
|
||||
{
|
||||
string file;
|
||||
string directory;
|
||||
string weekOfYear;
|
||||
DateTime dateTime;
|
||||
DateTime nowDateTime = DateTime.Now;
|
||||
string lastDirectory = string.Empty;
|
||||
DateTime firstEmail = new(2019, 3, 8);
|
||||
Calendar calendar = new CultureInfo("en-US").Calendar;
|
||||
const string line = "*** *** *** *** *** *** *** *** ***";
|
||||
double totalDays = new TimeSpan(nowDateTime.AddDays(1000).Ticks - firstEmail.Ticks).TotalDays;
|
||||
int days = (int)Math.Ceiling(totalDays);
|
||||
for (int i = 0; i < days; i++)
|
||||
{
|
||||
dateTime = firstEmail.AddDays(i);
|
||||
weekOfYear = calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
|
||||
directory = Path.Combine(argsZero, nowDateTime.Ticks.ToString(), dateTime.ToString("yyyy"), $"Week_{weekOfYear}");
|
||||
if (!Directory.Exists(directory))
|
||||
_ = Directory.CreateDirectory(directory);
|
||||
file = string.Concat(Path.Combine(directory, $"{dateTime:yyyy-MM-dd}.txt"));
|
||||
if (File.Exists(file))
|
||||
continue;
|
||||
File.WriteAllLines(file, new string[] { dateTime.ToString("dddd"), line, line, line, "", "TODO:", line, line, "", "Notes:", line, line });
|
||||
if (directory != lastDirectory)
|
||||
{
|
||||
Directory.SetCreationTime(directory, dateTime);
|
||||
Directory.SetLastWriteTime(directory, dateTime);
|
||||
}
|
||||
lastDirectory = directory;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -13,10 +13,10 @@ internal static class HelperILMerge
|
||||
StringBuilder stringBuilder = new();
|
||||
string[] successChecks = new string[] { "success" };
|
||||
string[] errorChecks = new string[] { "Error", "Conflict", "error:" };
|
||||
FileInfo ilMerge = new("C:/Users/phares/AppData/Local/IFXApps/ILMerge/ILMerge.exe");
|
||||
string[] dllFiles = Directory.GetFiles(workingDirectory, "*.dll", SearchOption.TopDirectoryOnly);
|
||||
string errorFile = Path.Combine(workingDirectory, string.Concat(Path.GetFileName(workingDirectory), ".err"));
|
||||
string primaryFile = Path.Combine(workingDirectory, string.Concat(Path.GetFileName(workingDirectory), ".dll"));
|
||||
string[] dllFiles = Directory.GetFiles(workingDirectory, "*.dll", SearchOption.TopDirectoryOnly);
|
||||
FileInfo ilMerge = new(@"C:\Users\phares\AppData\Local\IFXApps\ILMerge\ILMerge.exe");
|
||||
FileInfo fileInfo = new(Path.Combine(workingDirectory, ilMerge.Name));
|
||||
if (!fileInfo.Exists)
|
||||
_ = ilMerge.CopyTo(fileInfo.FullName);
|
||||
|
@ -54,17 +54,17 @@ internal static class HelperLogMerge
|
||||
dateTime = DateTime.ParseExact(keyValuePair.Key, format, CultureInfo.InvariantCulture);
|
||||
foreach (KeyValuePair<int, string[]> item in keyValuePair.Value.OrderBy(l => l.Key))
|
||||
lines.AddRange(item.Value);
|
||||
logFile = string.Concat(argsZero, @"\", dateTime.ToString("yyyy-MM-dd"), "_", segment1, ".log");
|
||||
logFile = Path.Combine(argsZero, $"{dateTime:yyyy-MM-dd}_{segment1}.log");
|
||||
File.WriteAllLines(logFile, lines);
|
||||
if (dateTime.Hour == 0 && dateTime.Minute == 0 && dateTime.Second == 0 && dateTime.Millisecond == 0)
|
||||
_ = dateTime.AddHours(23).AddMinutes(59).AddSeconds(59);
|
||||
File.SetLastWriteTime(logFile, dateTime);
|
||||
}
|
||||
checkDirectory = string.Concat(argsZero, @"\_ Merged");
|
||||
checkDirectory = Path.Combine(argsZero, "_ Merged");
|
||||
if (!Directory.Exists(checkDirectory))
|
||||
_ = Directory.CreateDirectory(checkDirectory);
|
||||
foreach (string moveFile in moveFiles.Distinct())
|
||||
File.Move(moveFile, string.Concat(checkDirectory, @"\", Path.GetFileName(moveFile)));
|
||||
File.Move(moveFile, Path.Combine(checkDirectory, Path.GetFileName(moveFile)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,10 @@ internal static class HelperSaveOrCopyContents
|
||||
long now = DateTime.Now.Ticks;
|
||||
StringBuilder data = new();
|
||||
string[] dataCollection;
|
||||
string filePathAndName = string.Concat(Path.GetDirectoryName(argsZero), @"\", fileName, ".txt");
|
||||
string? parentDirectory = Path.GetDirectoryName(argsZero);
|
||||
if (string.IsNullOrEmpty(parentDirectory))
|
||||
throw new Exception();
|
||||
string filePathAndName = Path.Combine(parentDirectory, $"{fileName}.txt");
|
||||
if (alongSideTopDirectoryOnly)
|
||||
File.WriteAllText(filePathAndName, string.Empty);
|
||||
else if (alongSideAllDirectories)
|
||||
|
@ -19,23 +19,26 @@ internal static class HelperZipFilesByDate
|
||||
FileInfo fileInfo;
|
||||
DateTime creationTime;
|
||||
DateTime lastWriteTime;
|
||||
DateTime nowDateTime = DateTime.Now;
|
||||
Regex regex = new("[a-zA-Z0-9]{1,}");
|
||||
DateTime dateTime = DateTime.Now.AddDays(-6);
|
||||
DateTime dateTime = DateTime.MinValue;
|
||||
DateTime firstEmail = new(2019, 3, 8);
|
||||
CultureInfo cultureInfo = new("en-US");
|
||||
Calendar calendar = cultureInfo.Calendar;
|
||||
int ticksLength = dateTime.Ticks.ToString().Length;
|
||||
Dictionary<string, DateTime> weeks = new();
|
||||
for (int i = 0; i < 1000; i++)
|
||||
int ticksLength = nowDateTime.AddDays(-6).Ticks.ToString().Length;
|
||||
for (int i = 0; i < int.MaxValue; i++)
|
||||
{
|
||||
dateTime = firstEmail.AddDays(i);
|
||||
if (dateTime > nowDateTime)
|
||||
break;
|
||||
weekOfYear = calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
|
||||
key = string.Concat(dateTime.ToString("yyyy"), "_Week_", weekOfYear);
|
||||
if (!weeks.ContainsKey(key))
|
||||
weeks.Add(key, dateTime);
|
||||
}
|
||||
weekOfYear = calendar.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
|
||||
string skipKey = string.Concat(DateTime.Now.ToString("yyyy"), "_Week_", weekOfYear);
|
||||
weekOfYear = calendar.GetWeekOfYear(nowDateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
|
||||
string skipKey = string.Concat(nowDateTime.ToString("yyyy"), "_Week_", weekOfYear);
|
||||
Dictionary<string, List<string>> keyValuePairs = new();
|
||||
string[] topDirectories = Directory.GetDirectories(sourceDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||
if (topDirectories.Length == 0)
|
||||
@ -95,12 +98,12 @@ internal static class HelperZipFilesByDate
|
||||
}
|
||||
foreach (KeyValuePair<string, List<string>> element in keyValuePairs)
|
||||
{
|
||||
key = string.Concat(topDirectory, @"\", element.Key, ".zip");
|
||||
key = Path.Combine(topDirectory, $"{element.Key}.zip");
|
||||
if (File.Exists(key))
|
||||
{
|
||||
for (short i = 101; i < short.MaxValue; i++)
|
||||
{
|
||||
key = string.Concat(topDirectory, @"\", element.Key, "_", i, ".zip");
|
||||
key = Path.Combine(topDirectory, $"{element.Key}_{i}.zip");
|
||||
if (!File.Exists(key))
|
||||
break;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ internal abstract class WorkingDirectory
|
||||
{
|
||||
if (!Directory.Exists(result))
|
||||
_ = Directory.CreateDirectory(result);
|
||||
traceFile = string.Concat(result, @"\", DateTime.Now.Ticks, ".txt");
|
||||
traceFile = Path.Combine(result, $"{DateTime.Now.Ticks}.txt");
|
||||
File.WriteAllText(traceFile, traceFile);
|
||||
File.Delete(traceFile);
|
||||
break;
|
||||
|
@ -45,6 +45,7 @@ internal class Program
|
||||
ConsoleKey.E,
|
||||
ConsoleKey.F,
|
||||
ConsoleKey.L,
|
||||
ConsoleKey.N,
|
||||
ConsoleKey.R,
|
||||
ConsoleKey.T,
|
||||
ConsoleKey.Z,
|
||||
@ -79,6 +80,7 @@ internal class Program
|
||||
log.Information("E) Clipboard (Top Directory Only and File Name Without Extension),");
|
||||
log.Information("F) Clipboard (All Directories and File Name Without Extension),");
|
||||
log.Information("L) Log Merge (APC Log [0-9{8}]_*.log),");
|
||||
log.Information("N) Create Note Files,");
|
||||
log.Information("R) Rename to old, copy, delete old");
|
||||
log.Information("T) Too long rename");
|
||||
log.Information("Z) Zip file(s) by date,");
|
||||
@ -98,6 +100,9 @@ internal class Program
|
||||
case ConsoleKey.L:
|
||||
Helpers.HelperLogMerge.LogMerge(args[0]);
|
||||
break;
|
||||
case ConsoleKey.N:
|
||||
Helpers.HelperCreateNoteFiles.CreateNoteFiles(args[0]);
|
||||
break;
|
||||
case ConsoleKey.R:
|
||||
Helpers.HelperRenameToOldMoveDeleteOldMerge.RenameToOldMoveDeleteOld(log, args[0]);
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user