diff --git a/PdfScribe/App.config b/PdfScribe/App.config index 36a68b3..7ba8ded 100644 --- a/PdfScribe/App.config +++ b/PdfScribe/App.config @@ -39,6 +39,9 @@ True + + yyyy_MM_dd_HH_mm_ss + diff --git a/PdfScribe/Program_2.cs b/PdfScribe/Program_2.cs index 6636d5f..675f1bc 100644 --- a/PdfScribe/Program_2.cs +++ b/PdfScribe/Program_2.cs @@ -98,12 +98,28 @@ ex is NotSupportedException || private static String GetOutputFilename() { - String outputFilename = Path.GetFullPath(Environment.ExpandEnvironmentVariables(Properties.Settings.Default.OutputFile)); + string rawFilename = Properties.Settings.Default.OutputFile; + + if (rawFilename.Contains("%DATETIME%")) + { + string format = Properties.Settings.Default.DatetimeFormat; + if (string.IsNullOrWhiteSpace(format)) + { + format = "yyyy_MM_dd_HH_mm_ss"; // Fallback + } + + string datetimeString = DateTime.Now.ToString(format); + rawFilename = rawFilename.Replace("%DATETIME%", datetimeString); + } + + string outputFilename = Path.GetFullPath(Environment.ExpandEnvironmentVariables(rawFilename)); + // Check if there are any % characters - // even though it's a legal Windows filename character, // it is a special character to Ghostscript if (outputFilename.Contains("%")) throw new ArgumentException("OutputFile setting contains % character."); + return outputFilename; } diff --git a/PdfScribe/Properties/Settings.Designer.cs b/PdfScribe/Properties/Settings.Designer.cs index c464d8c..c3eb144 100644 --- a/PdfScribe/Properties/Settings.Designer.cs +++ b/PdfScribe/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace PdfScribe.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.4.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.14.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); @@ -58,5 +58,14 @@ public bool StripNoRedistill { return ((bool)(this["StripNoRedistill"])); } } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("yyyy_MM_dd_HH_mm_ss")] + public string DatetimeFormat { + get { + return ((string)(this["DatetimeFormat"])); + } + } } } diff --git a/PdfScribe/Properties/Settings.settings b/PdfScribe/Properties/Settings.settings index cb4e7c6..380b68c 100644 --- a/PdfScribe/Properties/Settings.settings +++ b/PdfScribe/Properties/Settings.settings @@ -14,5 +14,8 @@ True + + yyyy_MM_dd_HH_mm_ss + \ No newline at end of file