diff --git a/SabreTools.Library/DatFiles/DatFile.cs b/SabreTools.Library/DatFiles/DatFile.cs index 3faea580..77cdcac1 100644 --- a/SabreTools.Library/DatFiles/DatFile.cs +++ b/SabreTools.Library/DatFiles/DatFile.cs @@ -3405,6 +3405,9 @@ namespace SabreTools.Library.DatFiles /// True if the DAT was written correctly, false otherwise public bool Write(string outDir, bool norename = true, bool stats = false, bool ignoreblanks = false, bool overwrite = true) { + // Force a statistics recheck, just in case + Items.RecalculateStats(); + // If there's nothing there, abort if (Items.TotalCount == 0) { @@ -3412,6 +3415,20 @@ namespace SabreTools.Library.DatFiles return false; } + // Get a count of all removed items + long removed = 0; + foreach (string key in Items.Keys) + { + removed += Items[key].Count(i => i.Remove); + } + + // If every item is removed, abort + if (Items.TotalCount == removed) + { + Globals.Logger.User("There were no items to write out!"); + return false; + } + // Ensure the output directory is set and created outDir = DirectoryExtensions.Ensure(outDir, create: true);