diff --git a/MainWindow.xaml b/MainWindow.xaml
index b572825..4451391 100644
--- a/MainWindow.xaml
+++ b/MainWindow.xaml
@@ -19,7 +19,7 @@
-
+
@@ -38,9 +38,13 @@
+
+
+
+
-
-
+
+
@@ -50,7 +54,7 @@
-
+
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index d70fbe6..4fc5374 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -141,8 +141,22 @@ namespace TapeCatalog
#region (COPY_TO_TAPECATALOG)
private void COPY_TO_TAPECATALOG(object sender, RoutedEventArgs e)
{
- // delegate to XML helper to copy entries to TapeCatalog list view
- XML.Methods.CopyToTapeCatalog(this, _files, TapeCatalogListView);
+ // Only copy entries where the verification status indicates OK (checked)
+ try
+ {
+ var okEntries = _files.Where(f => string.Equals(f.Status, "✔", StringComparison.Ordinal)).ToList();
+ if (okEntries.Count == 0)
+ {
+ MessageBox.Show(this, "No verified entries to copy to TapeCatalog.", "Nothing to copy", MessageBoxButton.OK, MessageBoxImage.Information);
+ return;
+ }
+
+ XML.Methods.CopyToTapeCatalog(this, okEntries, TapeCatalogListView);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(this, $"Error copying to TapeCatalog: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
}
#endregion (COPY_TO_TAPECATALOG)
#region (COPY_FROM_SRCARC)
diff --git a/Methods/Settings.cs b/Methods/Settings.cs
index 79d877c..baba20e 100644
--- a/Methods/Settings.cs
+++ b/Methods/Settings.cs
@@ -87,13 +87,24 @@ namespace TapeCatalog.Methods
if (string.IsNullOrWhiteSpace(path)) throw new ArgumentException("path");
if (!Directory.Exists(path)) throw new DirectoryNotFoundException(path);
+ // normalize source root for reliable relative path calculation
+ var rootFull = System.IO.Path.GetFullPath(path).TrimEnd(System.IO.Path.DirectorySeparatorChar, System.IO.Path.AltDirectorySeparatorChar);
+
foreach (var file in Directory.EnumerateFiles(path, "*.*", SearchOption.AllDirectories))
{
try
{
var fi = new FileInfo(file);
+ // compute directory relative to source root (remove the source root prefix)
+ var dirFull = System.IO.Path.GetFullPath(fi.DirectoryName).TrimEnd(System.IO.Path.DirectorySeparatorChar, System.IO.Path.AltDirectorySeparatorChar);
+ string relativeDir = string.Empty;
+ if (dirFull.StartsWith(rootFull, StringComparison.OrdinalIgnoreCase))
+ relativeDir = dirFull.Length == rootFull.Length ? string.Empty : dirFull.Substring(rootFull.Length).TrimStart(System.IO.Path.DirectorySeparatorChar, System.IO.Path.AltDirectorySeparatorChar);
+ else
+ relativeDir = fi.DirectoryName;
+
var existing = files.FirstOrDefault(f => string.Equals(f.Filename, fi.Name, StringComparison.OrdinalIgnoreCase)
- && string.Equals(f.FileDir, fi.DirectoryName, StringComparison.OrdinalIgnoreCase));
+ && string.Equals(f.FileDir, relativeDir, StringComparison.OrdinalIgnoreCase));
if (existing != null)
{
var newSizeMb = FormatBytesToMb(fi.Length);
@@ -110,7 +121,7 @@ namespace TapeCatalog.Methods
files.Add(new TapeCatalog.FileEntry
{
Filename = fi.Name,
- FileDir = fi.DirectoryName,
+ FileDir = relativeDir,
SizeSrc = FormatBytesToMb(fi.Length),
ModSrc = fi.LastWriteTime.ToString(),
});
@@ -128,13 +139,24 @@ namespace TapeCatalog.Methods
{
if (string.IsNullOrWhiteSpace(path)) throw new ArgumentException("path");
if (!Directory.Exists(path)) throw new DirectoryNotFoundException(path);
+ // normalize archive root for reliable relative path calculation
+ var rootFull = System.IO.Path.GetFullPath(path).TrimEnd(System.IO.Path.DirectorySeparatorChar, System.IO.Path.AltDirectorySeparatorChar);
foreach (var file in Directory.EnumerateFiles(path, "*.*", SearchOption.AllDirectories))
{
try
{
var fi = new FileInfo(file);
- var existing = files.FirstOrDefault(f => string.Equals(f.Filename, fi.Name, StringComparison.Ordinal));
+
+ var dirFull = System.IO.Path.GetFullPath(fi.DirectoryName).TrimEnd(System.IO.Path.DirectorySeparatorChar, System.IO.Path.AltDirectorySeparatorChar);
+ string relativeDir = string.Empty;
+ if (dirFull.StartsWith(rootFull, StringComparison.OrdinalIgnoreCase))
+ relativeDir = dirFull.Length == rootFull.Length ? string.Empty : dirFull.Substring(rootFull.Length).TrimStart(System.IO.Path.DirectorySeparatorChar, System.IO.Path.AltDirectorySeparatorChar);
+ else
+ relativeDir = fi.DirectoryName;
+
+ var existing = files.FirstOrDefault(f => string.Equals(f.Filename, fi.Name, StringComparison.Ordinal)
+ && string.Equals(f.FileDir, relativeDir, StringComparison.OrdinalIgnoreCase));
if (existing != null)
{
existing.SizeArc = FormatBytesToMb(fi.Length);
@@ -148,7 +170,7 @@ namespace TapeCatalog.Methods
files.Add(new TapeCatalog.FileEntry
{
Filename = fi.Name,
- FileDir = fi.DirectoryName,
+ FileDir = relativeDir,
SizeArc = FormatBytesToMb(fi.Length),
ModArc = fi.LastWriteTime.ToString()
});