Moved from Google Photos
This commit is contained in:
@ -25,6 +25,7 @@ public class Rename
|
||||
{ }
|
||||
if (console is null)
|
||||
{ }
|
||||
bool any = false;
|
||||
_AppSettings = appSettings;
|
||||
_IsEnvironment = isEnvironment;
|
||||
long ticks = DateTime.Now.Ticks;
|
||||
@ -46,16 +47,29 @@ public class Rename
|
||||
MatchNginx[]? matchNginxCollection = JsonSerializer.Deserialize<MatchNginx[]>(json);
|
||||
if (matchNginxCollection is null)
|
||||
throw new NullReferenceException(nameof(matchNginxCollection));
|
||||
if (matchNginxCollection.Length == 0 && matchNginxCollection[0].ConvertedPath.Contains("~~~"))
|
||||
MoveMatches(matchNginxCollection[0]);
|
||||
else if (matchNginxCollection.All(l => l.Name.StartsWith("#")) || matchNginxCollection.All(l => l.Name.StartsWith(" #")) || matchNginxCollection.All(l => l.Name.StartsWith("=20")) || matchNginxCollection.All(l => l.Name.StartsWith("#20")))
|
||||
Rename2000(matchNginxCollection);
|
||||
else if (matchNginxCollection.Any())
|
||||
if (matchNginxCollection.Any())
|
||||
{
|
||||
List<string> lines = RenameFilesInDirectories(log, matchNginxCollection);
|
||||
File.WriteAllLines($"D:/Tmp/Phares/{DateTime.Now.Ticks}.tsv", lines);
|
||||
if (comparePathRoot != Path.GetPathRoot(matchNginxCollection[0].ConvertedPath))
|
||||
_ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(comparePathRoot);
|
||||
bool deleted;
|
||||
for (int i = 1; i < 5; i++)
|
||||
{
|
||||
deleted = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(matchNginxCollection.First().ConvertedPath);
|
||||
if (deleted && !any)
|
||||
any = true;
|
||||
}
|
||||
}
|
||||
if (!any)
|
||||
{
|
||||
if (matchNginxCollection.Length == 0 && matchNginxCollection[0].ConvertedPath.Contains("~~~"))
|
||||
MoveMatches(matchNginxCollection[0]);
|
||||
else if (matchNginxCollection.All(l => l.Name.StartsWith("#")) || matchNginxCollection.All(l => l.Name.StartsWith(" #")) || matchNginxCollection.All(l => l.Name.StartsWith("=20")) || matchNginxCollection.All(l => l.Name.StartsWith("#20")))
|
||||
Rename2000(log, matchNginxCollection);
|
||||
else if (matchNginxCollection.Any())
|
||||
{
|
||||
List<string> lines = RenameFilesInDirectories(log, matchNginxCollection);
|
||||
File.WriteAllLines($"D:/Tmp/Phares/{DateTime.Now.Ticks}.tsv", lines);
|
||||
if (comparePathRoot != Path.GetPathRoot(matchNginxCollection[0].ConvertedPath))
|
||||
_ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(comparePathRoot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -262,11 +276,13 @@ public class Rename
|
||||
return results;
|
||||
}
|
||||
|
||||
private static void Rename2000(MatchNginx[] matchNginxCollection)
|
||||
private static void Rename2000(ILogger log, MatchNginx[] matchNginxCollection)
|
||||
{
|
||||
string name;
|
||||
string check;
|
||||
string? directoryName;
|
||||
log.Information("Enter a suffix if any");
|
||||
string? suffix = System.Console.ReadLine();
|
||||
foreach (MatchNginx matchNginx in matchNginxCollection)
|
||||
{
|
||||
name = matchNginx.Name.Trim();
|
||||
@ -276,7 +292,7 @@ public class Rename
|
||||
if (directoryName is null)
|
||||
continue;
|
||||
if (name.StartsWith("=20") || name.StartsWith("#20"))
|
||||
check = Path.Combine(directoryName, name[1..]);
|
||||
check = Path.Combine(directoryName, $"{name[1..]}{suffix}");
|
||||
else
|
||||
check = Path.Combine(directoryName, $"zzz {name[5..]}");
|
||||
if (Directory.Exists(check) || File.Exists(check))
|
||||
|
Reference in New Issue
Block a user