added "ReplaceOriginal" node

fixed spelling mistakes
This commit is contained in:
reven
2021-12-05 21:55:55 +13:00
parent 004930f57d
commit 69d183417f
10 changed files with 71 additions and 7 deletions

Binary file not shown.

View File

@@ -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": {

View File

@@ -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;
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -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":{

View File

@@ -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"
}
]