diff --git a/BasicNodes/BasicNodes.csproj b/BasicNodes/BasicNodes.csproj index c7e7d9b6..f3800900 100644 Binary files a/BasicNodes/BasicNodes.csproj and b/BasicNodes/BasicNodes.csproj differ diff --git a/BasicNodes/BasicNodes.en.json b/BasicNodes/BasicNodes.en.json index 7570ed6d..14a7f66c 100644 --- a/BasicNodes/BasicNodes.en.json +++ b/BasicNodes/BasicNodes.en.json @@ -34,7 +34,7 @@ "Description": "Checks if the file has one of the configured extensions.\n\nOutput 1: Matches\nOutput 2: Does not match", "Fields": { "Extensions": "Extensions", - "Extensions-Help": "A list of case insensitive file extensions that will be matched against.\nOuput 1 Matches\nOutput 2: Does not match" + "Extensions-Help": "A list of case insensitive file extensions that will be matched against.\nOutput 1 Matches\nOutput 2: Does not match" } }, "FileSize": { @@ -83,7 +83,7 @@ } }, "PatternReplacer": { - "Description": "Lets you make replacements in the filename. Can use regular expressions for replacements, or simple string raplacements.\n\nOutput 1: Replacement done\nOutput 2: No replacement done", + "Description": "Lets you make replacements in the filename. Can use regular expressions for replacements, or simple string replacements.\n\nOutput 1: Replacement done\nOutput 2: No replacement done", "Fields": { "Replacements": "Replacements", "ReplacementsKey": "Pattern", @@ -92,6 +92,9 @@ "UseWorkingFileName-Help": "If current working filename should be used, or if false, the original filename of the incoming file will be used." } }, + "ReplaceOriginal": { + "Description": "Replaces the original file with the working file.\n\nIf the extension is different on the working file, the original file will be deleted and the working file will be moved to the original with the new extension.\nE.g. from File.avi to File.mkv" + }, "Renamer": { "Description": "Renames the working file.\nVariables can be used by entering the key '{' inside the Pattern field.", "Fields": { diff --git a/BasicNodes/File/ReplaceOriginal.cs b/BasicNodes/File/ReplaceOriginal.cs new file mode 100644 index 00000000..d384cd15 --- /dev/null +++ b/BasicNodes/File/ReplaceOriginal.cs @@ -0,0 +1,61 @@ +namespace FileFlows.BasicNodes.File +{ + using System.Text; + using System.Text.RegularExpressions; + using FileFlows.Plugin; + + public class ReplaceOriginal : Node + { + public override int Inputs => 1; + public override int Outputs => 1; + public override string Icon => "fas fa-font"; + + public string _Pattern = string.Empty; + + public override FlowElementType Type => FlowElementType.Process; + + public override int Execute(NodeParameters args) + { + if (args.FileName == args.WorkingFile) + { + args.Logger?.ILog("Working file is same as original, nothing to do."); + return 1; + } + var wf = new FileInfo(args.WorkingFile); + if (args.FileName.ToLower().EndsWith(wf.Extension.ToLower())) + { + // easy replace + bool moved = args.MoveFile(args.FileName); + if(moved == false) + { + args.Logger?.ELog("Failed to move file to: "+ args.FileName); + return -11; + } + } + else + { + // different extension, we will move the file, but then delete the original + string dest = Path.ChangeExtension(args.FileName, wf.Extension); + if(args.MoveFile(dest) == false) + { + args.Logger?.ELog("Failed to move file to: " + dest); + return 1; + } + if (dest.ToLower() != args.FileName.ToLower()) + { + try + { + System.IO.File.Delete(args.FileName); + } + catch (Exception ex) + { + args.Logger?.ELog("Failed to delete orginal (with different extension): " + ex.Message); + return -1; + } + } + } + + return 1; + } + } +} diff --git a/Builds/BasicNodes.zip b/Builds/BasicNodes.zip index 0c173540..51adeb7e 100644 Binary files a/Builds/BasicNodes.zip and b/Builds/BasicNodes.zip differ diff --git a/Builds/MetaNodes.zip b/Builds/MetaNodes.zip index bb5b8355..eece5062 100644 Binary files a/Builds/MetaNodes.zip and b/Builds/MetaNodes.zip differ diff --git a/Builds/VideoNodes.zip b/Builds/VideoNodes.zip index d31a1c29..04b5c8ff 100644 Binary files a/Builds/VideoNodes.zip and b/Builds/VideoNodes.zip differ diff --git a/MetaNodes/MetaNodes.csproj b/MetaNodes/MetaNodes.csproj index 37e95173..00e81eaf 100644 Binary files a/MetaNodes/MetaNodes.csproj and b/MetaNodes/MetaNodes.csproj differ diff --git a/VideoNodes/VideoNodes.csproj b/VideoNodes/VideoNodes.csproj index 2176a1b3..1f3ce970 100644 Binary files a/VideoNodes/VideoNodes.csproj and b/VideoNodes/VideoNodes.csproj differ diff --git a/VideoNodes/VideoNodes.en.json b/VideoNodes/VideoNodes.en.json index 52323edc..ce3e8303 100644 --- a/VideoNodes/VideoNodes.en.json +++ b/VideoNodes/VideoNodes.en.json @@ -42,8 +42,8 @@ "Threads-Help": "Only used if not using NVIDIA. If set to 0, the threads will use FFMpegs defaults.", "NormalizeAudio": "Normalize Audio", "NormalizeAudio-Help": "If the audio track should have its volume level normalized", - "ForceRencode": "Force Rencode", - "ForceRencode-Help": "If the video should always be reencoded regardless if it already is in H265/AC3" + "ForceRencode": "Force Re-Encode", + "ForceRencode-Help": "If the video should always be re-encoded regardless if it already is in H265/AC3" } }, "FFMPEG":{ diff --git a/plugins.json b/plugins.json index 09197177..097afbe9 100644 --- a/plugins.json +++ b/plugins.json @@ -1,17 +1,17 @@ [ { "Name": "BasicNodes", - "Version": "0.0.1.19", + "Version": "0.0.1.20", "Package": "https://github.com/revenz/FileFlowsPlugins/blob/master/Builds/BasicNodes.zip?raw=true" }, { "Name": "MetaNodes", - "Version": "0.0.1.19", + "Version": "0.0.1.20", "Package": "https://github.com/revenz/FileFlowsPlugins/blob/master/Builds/MetaNodes.zip?raw=true" }, { "Name": "VideoNodes", - "Version": "0.0.1.19", + "Version": "0.0.1.20", "Package": "https://github.com/revenz/FileFlowsPlugins/blob/master/Builds/VideoNodes.zip?raw=true" } ]