diff --git a/SabreTools.Library/DatFiles/DatFile.cs b/SabreTools.Library/DatFiles/DatFile.cs
index 8e2235ba..b2002c01 100644
--- a/SabreTools.Library/DatFiles/DatFile.cs
+++ b/SabreTools.Library/DatFiles/DatFile.cs
@@ -1684,7 +1684,7 @@ namespace SabreTools.Library.DatFiles
Parallel.For(0, inputs.Count, Globals.ParallelOptions, j =>
{
- string innerpost = " (" + j + " - " + Path.GetFileNameWithoutExtension(inputs[j].Split('¬')[0]) + " Only)";
+ string innerpost = " (" + j + " - " + Utilities.GetFilenameFromFileAndParent(inputs[j], true) + " Only)";
DatFile diffData;
// If we're in inplace mode, take the appropriate DatData object already stored
@@ -1816,7 +1816,7 @@ namespace SabreTools.Library.DatFiles
Parallel.For(0, inputs.Count, Globals.ParallelOptions, j =>
{
- string innerpost = " (" + j + " - " + Path.GetFileNameWithoutExtension(inputs[j].Split('¬')[0]) + " Only)";
+ string innerpost = " (" + j + " - " + Utilities.GetFilenameFromFileAndParent(inputs[j], true) + " Only)";
DatFile diffData = new DatFile(this);
diffData.FileName += innerpost;
diffData.Name += innerpost;
diff --git a/SabreTools.Library/Tools/Utilities.cs b/SabreTools.Library/Tools/Utilities.cs
index 09ce26c6..71159ea7 100644
--- a/SabreTools.Library/Tools/Utilities.cs
+++ b/SabreTools.Library/Tools/Utilities.cs
@@ -2583,6 +2583,34 @@ namespace SabreTools.Library.Tools
return ext;
}
+ ///
+ /// Get the proper filename (with subpath) from the file and parent combination
+ ///
+ /// Input combined path to use
+ /// True if path separators should be converted to '-', false otherwise
+ /// Subpath for the file
+ public static string GetFilenameFromFileAndParent(string path, bool sanitize)
+ {
+ // Check that we have a combined path first
+ if (!path.Contains("¬"))
+ {
+ return Path.GetFileName(path).Replace('/', '-').Replace('\\', '-');
+ }
+
+ // First separate out the parts
+ string child = path.Split('¬')[0];
+ string parent = path.Split('¬')[1];
+
+ // If the parts are the same, return the filename from the first part
+ if (child == parent)
+ {
+ return Path.GetFileName(child).Replace('/', '-').Replace('\\', '-');
+ }
+
+ // Otherwise, remove the parent from the child and return the remainder
+ return child.Remove(0, parent.Length + 1).Replace('/', '-').Replace('\\', '-');
+ }
+
///
/// Get the dictionary key that should be used for a given item and sorting type
///