diff --git a/AudioNodes/AudioBooks/CreateAudioBook.cs b/AudioNodes/AudioBooks/CreateAudioBook.cs
index a0061fc0..f04d9ba3 100644
--- a/AudioNodes/AudioBooks/CreateAudioBook.cs
+++ b/AudioNodes/AudioBooks/CreateAudioBook.cs
@@ -1,4 +1,5 @@
using FileFlows.Plugin;
+using TagLib.Tiff.Cr2;
namespace FileFlows.AudioNodes;
@@ -32,6 +33,23 @@ public class CreateAudioBook: AudioNode
///
public override FlowElementType Type => FlowElementType.Process;
+ ///
+ /// Gets or sets the destination path
+ ///
+ [Required]
+ [Folder(1)]
+ public string DestinationPath { get; set; }
+
+ ///
+ /// Gets or sets if the source files should be deleted
+ ///
+ [Boolean(2)] public bool DeleteSourceFiles { get; set; }
+
+ ///
+ /// Gets or sets if the working file should be updated
+ ///
+ [Boolean(3)] public bool UpdateWorkingFile { get; set; }
+
///
/// Executes the flow element
///
@@ -185,7 +203,41 @@ public class CreateAudioBook: AudioNode
args.Logger.ELog("Failed to create output file: " + outputFile);
return -1;
}
- args.Logger.ELog("Created output file: " + outputFile);
+ args.Logger.ILog("Created output file: " + outputFile);
+
+ if (DeleteSourceFiles)
+ {
+ foreach (var file in files)
+ {
+ var result = args.FileService.FileDelete(file);
+ if(result.IsFailed)
+ args.Logger.ILog("Failed deleting source file: " + file + " -> " + result.Error);
+ else if(result.Value == false)
+ args.Logger.ILog("Failed deleting source file: " + file);
+ else
+ args.Logger.ILog("Deleted source file: " + file);
+ }
+ }
+
+ if (string.IsNullOrWhiteSpace(DestinationPath) == false)
+ {
+ var dest = args.ReplaceVariables(DestinationPath, stripMissing: true);
+ if (args.FileService.FileMove(outputFile, dest).Failed(out string error))
+ {
+ args.Logger?.ELog("Failed to save to destination: " + error);
+ return -1;
+ }
+
+ outputFile = dest;
+ }
+
+ if (UpdateWorkingFile)
+ {
+ args.Logger?.ILog("Updating working file to: " + outputFile);
+ args.IsDirectory = false; // no longer a directory based flow
+ args.SetWorkingFile(outputFile);
+ }
+
return 1;
}
diff --git a/AudioNodes/AudioNodes.en.json b/AudioNodes/AudioNodes.en.json
index f956060c..59197f7c 100644
--- a/AudioNodes/AudioNodes.en.json
+++ b/AudioNodes/AudioNodes.en.json
@@ -114,6 +114,14 @@
"Outputs": {
"1": "Audio book created",
"2": "Audio book not created"
+ },
+ "Fields": {
+ "DeleteSourceFiles": "Delete Source Files",
+ "DeleteSourceFiles-Help": "When enabled the source files that make up the newly created m4b file will be deleted, otherwise they will be left alone.",
+ "UpdateWorkingFile": "Update Working File",
+ "UpdateWorkingFile-Help": "When enabled the working file will be updated to the newly created file.",
+ "DestinationPath": "Destination Path",
+ "DestinationPath-Help": "The destination where to save the newly created file. If left empty the file will be created in the temporary directory and will be deleted if not moved afterwards."
}
}
}