PersonCharactersCopyCount

This commit is contained in:
2023-01-01 22:19:21 -07:00
parent 1417d87930
commit af24897853
25 changed files with 251 additions and 187 deletions

View File

@ -394,7 +394,7 @@ public partial class Form : System.Windows.Forms.Form
string? directoryName;
foreach (string path in paths)
{
name = Path.GetFileName(path);
name = Path.GetFileName(path).Trim();
if (name.Length < 1 || (!name.StartsWith("zzz =20") && !name.StartsWith("=20") && !name.StartsWith("#20")))
// if (name.Length < 1 || !name.Contains(".Z.#20"))
continue;
@ -463,33 +463,22 @@ public partial class Form : System.Windows.Forms.Form
_ProgressBar.Visible = false;
}
void Form1_DragDrop(object? sender, DragEventArgs e)
private static void MoveMatches(string argZero)
{
try
string moveDirectory;
string checkDirectory;
int length = argZero.Length;
string compareDirectory = "D:/";
string[] directories = Directory.GetDirectories(argZero, "*", SearchOption.TopDirectoryOnly);
foreach (string directory in directories)
{
if (e.Data is null || e.Data.GetData(DataFormats.FileDrop) is not string[] paths)
_TextBox.Text = string.Empty;
else
{
if (paths.All(l => l.Contains("=20")) || paths.All(l => l.Contains("#20")))
// if (paths.All(l => l.Contains('#')))
Rename2000(paths);
else
{
List<string> directories = GetDirectoriesOrDoDragDrop(paths);
if (directories.Any())
{
RenameFilesInDirectories(directories);
string? parentDirectory = Path.GetDirectoryName(directories[0]);
if (parentDirectory is not null && parentDirectory != Path.GetPathRoot(directories[0]))
_ = IPath.DeleteEmptyDirectories(parentDirectory);
}
}
}
}
catch (Exception)
{
throw;
if (!string.IsNullOrEmpty(directory))
continue;
checkDirectory = string.Concat(compareDirectory, directory[length..]);
if (!Directory.Exists(checkDirectory))
continue;
moveDirectory = string.Concat(compareDirectory[..^1], directory[length..]);
Directory.Move(checkDirectory, moveDirectory);
}
}
@ -526,4 +515,36 @@ public partial class Form : System.Windows.Forms.Form
return results;
}
void Form1_DragDrop(object? sender, DragEventArgs e)
{
try
{
if (e.Data is null || e.Data.GetData(DataFormats.FileDrop) is not string[] paths)
_TextBox.Text = string.Empty;
else
{
if (paths.Length == 0 && paths[0].Contains("~~~"))
MoveMatches(paths[0]);
else if (paths.All(l => l.Contains("=20")) || paths.All(l => l.Contains("#20")))
// if (paths.All(l => l.Contains('#')))
Rename2000(paths);
else
{
List<string> directories = GetDirectoriesOrDoDragDrop(paths);
if (directories.Any())
{
RenameFilesInDirectories(directories);
string? parentDirectory = Path.GetDirectoryName(directories[0]);
if (parentDirectory is not null && parentDirectory != Path.GetPathRoot(directories[0]))
_ = IPath.DeleteEmptyDirectories(parentDirectory);
}
}
}
}
catch (Exception)
{
throw;
}
}
}