diff --git a/BasicNodes/BasicNodes.en.json b/BasicNodes/BasicNodes.en.json
index c2d13376..3f71cf38 100644
--- a/BasicNodes/BasicNodes.en.json
+++ b/BasicNodes/BasicNodes.en.json
@@ -27,6 +27,9 @@
"1": "File copied"
},
"Fields": {
+ "InputFile": "File To Copy",
+ "InputFile-Help": "The file to copy, if left empty then the working file will be copied",
+ "InputFile-Placeholder": "Working File",
"DestinationPath": "Destination Folder",
"DestinationPath-Help": "The folder where the file will be copied to",
"DestinationFile": "Destination File",
@@ -187,6 +190,9 @@
"2": "File moved, however original file could not be deleted"
},
"Fields": {
+ "InputFile": "File To Move",
+ "InputFile-Help": "The file to move, if left empty then the working file will be moved",
+ "InputFile-Placeholder": "Working File",
"DestinationPath": "Destination Folder",
"DestinationPath-Help": "The folder where the file will be moved to",
"DestinationFile": "Destination File",
diff --git a/BasicNodes/File/CopyFile.cs b/BasicNodes/File/CopyFile.cs
index aefb4b69..3f24713a 100644
--- a/BasicNodes/File/CopyFile.cs
+++ b/BasicNodes/File/CopyFile.cs
@@ -38,33 +38,40 @@ namespace FileFlows.BasicNodes.File
private string _DestinationPath = string.Empty;
private string _DestinationFile = string.Empty;
+
+ ///
+ /// Gets or sets the input file to move
+ ///
+ [TextVariable(1)]
+ public string InputFile{ get; set; }
+
[Required]
- [Folder(1)]
+ [Folder(2)]
public string DestinationPath
{
get => _DestinationPath;
set { _DestinationPath = value ?? ""; }
}
- [TextVariable(2)]
+ [TextVariable(3)]
public string DestinationFile
{
get => _DestinationFile;
set { _DestinationFile = value ?? ""; }
}
- [Boolean(3)]
+ [Boolean(4)]
public bool CopyFolder { get; set; }
- [StringArray(4)]
+ [StringArray(5)]
public string[] AdditionalFiles { get; set; }
- [Boolean(5)]
+ [Boolean(6)]
public bool AdditionalFilesFromOriginal { get; set; }
///
/// Gets or sets if the original files creation and last write time dates should be preserved
///
- [Boolean(6)]
+ [Boolean(7)]
public bool PreserverOriginalDates { get; set; }
private bool Canceled;
@@ -80,43 +87,62 @@ namespace FileFlows.BasicNodes.File
{
Canceled = false;
+
var destParts = MoveFile.GetDestinationPathParts(args, DestinationPath, DestinationFile, CopyFolder);
if (destParts.Filename == null)
return -1;
+ string inputFile = args.ReplaceVariables(InputFile ?? string.Empty, stripMissing: true)?.EmptyAsNull() ?? args.WorkingFile;
+
// cant use new FileInfo(dest).Directory.Name here since
// if the folder is a linux folder and this node is running on windows
// /mnt, etc will be converted to c:\mnt and break the destination
var destDir = destParts.Path;
- string dest = destParts.Path + destParts.Separator + destParts.Filename;
+ var destFile = destParts.Filename;
+ if(inputFile != args.WorkingFile && string.IsNullOrWhiteSpace(DestinationFile))
+ {
+ destFile = FileHelper.GetShortFileName(inputFile);
+ }
+ string dest = FileHelper.Combine(destParts.Path, destFile);
//bool copied = args.CopyFile(args.WorkingFile, dest, updateWorkingFile: true);
//if (!copied)
// return -1;
-
- if (args.FileService.FileCopy(args.WorkingFile, dest, true).IsFailed)
- return -1;
- args.SetWorkingFile(dest);
+ args.Logger?.ILog("File to copy: " + inputFile);
+ args.Logger?.ILog("Destination: " + dest);
- if (PreserverOriginalDates)
+ if (args.FileService.FileCopy(inputFile, dest, true).Failed(out string error))
{
- if (args.Variables.TryGetValue("ORIGINAL_CREATE_UTC", out object oCreateTimeUtc) &&
- args.Variables.TryGetValue("ORIGINAL_LAST_WRITE_UTC", out object oLastWriteUtc) &&
- oCreateTimeUtc is DateTime dtCreateTimeUtc && oLastWriteUtc is DateTime dtLastWriteUtc)
+ args.FailureReason = "Failed to copy file: " + error;
+ args.Logger?.ELog(args.FailureReason);
+ return -1;
+ }
+
+ if (inputFile == args.WorkingFile)
+ {
+ args.Logger?.ILog("Setting working file to: " + dest);
+ args.SetWorkingFile(dest);
+
+ if (PreserverOriginalDates)
{
- args.Logger?.ILog("Preserving dates");
- Helpers.FileHelper.SetLastWriteTime(dest, dtLastWriteUtc);
- Helpers.FileHelper.SetCreationTime(dest, dtCreateTimeUtc);
- }
- else
- {
- args.Logger?.WLog("Preserve dates is on but failed to get original dates from variables");
+ if (args.Variables.TryGetValue("ORIGINAL_CREATE_UTC", out object oCreateTimeUtc) &&
+ args.Variables.TryGetValue("ORIGINAL_LAST_WRITE_UTC", out object oLastWriteUtc) &&
+ oCreateTimeUtc is DateTime dtCreateTimeUtc && oLastWriteUtc is DateTime dtLastWriteUtc)
+ {
+ args.Logger?.ILog("Preserving dates");
+ Helpers.FileHelper.SetLastWriteTime(dest, dtLastWriteUtc);
+ Helpers.FileHelper.SetCreationTime(dest, dtCreateTimeUtc);
+ }
+ else
+ {
+ args.Logger?.WLog("Preserve dates is on but failed to get original dates from variables");
+ }
}
}
var srcDir = FileHelper.GetDirectory(AdditionalFilesFromOriginal
? args.FileName
- : args.WorkingFile);
+ : inputFile);
if (AdditionalFiles?.Any() == true)
{
diff --git a/BasicNodes/File/MoveFile.cs b/BasicNodes/File/MoveFile.cs
index 5506ce53..87d2f6a0 100644
--- a/BasicNodes/File/MoveFile.cs
+++ b/BasicNodes/File/MoveFile.cs
@@ -32,49 +32,55 @@ public class MoveFile : Node
///
public override string HelpUrl => "https://fileflows.com/docs/plugins/basic-nodes/move-file";
+ ///
+ /// Gets or sets the input file to move
+ ///
+ [TextVariable(1)]
+ public string InputFile{ get; set; }
+
///
/// Gets or sets the destination path
///
[Required]
- [Folder(1)]
+ [Folder(2)]
public string DestinationPath { get; set; }
///
/// Gets or sets the destination file
///
- [TextVariable(2)]
+ [TextVariable(3)]
public string DestinationFile{ get; set; }
///
/// Gets or sets if the folder should be moved
///
- [Boolean(3)]
+ [Boolean(4)]
public bool MoveFolder { get; set; }
///
/// Gets or sets if the original should be deleted
///
- [Boolean(4)]
+ [Boolean(5)]
public bool DeleteOriginal { get; set; }
///
/// Gets or sets additional files that should also be moved
///
- [StringArray(5)]
+ [StringArray(6)]
public string[] AdditionalFiles { get; set; }
///
/// Gets or sets original files from the original file location that should also be moved
///
- [Boolean(6)]
+ [Boolean(7)]
public bool AdditionalFilesFromOriginal { get; set; }
///
/// Gets or sets if the original files creation and last write time dates should be preserved
///
- [Boolean(7)]
+ [Boolean(8)]
public bool PreserverOriginalDates { get; set; }
-
+
///
/// Executes the node
///
@@ -82,21 +88,54 @@ public class MoveFile : Node
/// the output to call next
public override int Execute(NodeParameters args)
{
- var dest = GetDestinationPath(args, DestinationPath, DestinationFile, MoveFolder);
+ string destFile = args.ReplaceVariables(DestinationFile ?? string.Empty);
+
+ string inputFile = args.ReplaceVariables(InputFile ?? string.Empty)?.EmptyAsNull() ?? args.WorkingFile;
+ if (inputFile != args.WorkingFile && string.IsNullOrWhiteSpace(DestinationFile))
+ destFile = FileHelper.GetShortFileName(inputFile);
+
+ var dest = GetDestinationPath(args, DestinationPath, destFile, MoveFolder);
if (dest == null)
+ {
+ args.FailureReason = "Failed to get move destination";
+ args.Logger?.ELog(args.FailureReason);
return -1;
+ }
+
+ if (inputFile != args.WorkingFile && string.IsNullOrWhiteSpace(destFile) == false)
+ dest = FileHelper.Combine(FileHelper.GetDirectory(dest), destFile); // ensure the non working file has correct extension/name
// store srcDir here before we move and the working file is altered
- var srcDir = FileHelper.GetDirectory(AdditionalFilesFromOriginal ? args.FileName : args.WorkingFile);
+ var srcDir = FileHelper.GetDirectory(AdditionalFilesFromOriginal ? args.FileName : inputFile);
args.Logger?.ILog("Source Directory: " + srcDir);
string shortNameLookup = FileHelper.GetShortFileName(args.FileName);
if (shortNameLookup.LastIndexOf(".", StringComparison.InvariantCulture) > 0)
- shortNameLookup = shortNameLookup.Substring(0, shortNameLookup.LastIndexOf(".", StringComparison.Ordinal));
+ shortNameLookup = shortNameLookup[..shortNameLookup.LastIndexOf(".", StringComparison.Ordinal)];
args.Logger?.ILog("shortNameLookup: " + shortNameLookup);
+
+ args.Logger?.ILog("Moving file: " + inputFile);
+ args.Logger?.ILog("Destination: " + dest);
- if (args.MoveFile(dest) == false)
- return -1;
+
+ if (inputFile == args.WorkingFile)
+ {
+ if (args.MoveFile(dest) == false)
+ {
+ args.FailureReason = "Failed to move file";
+ args.Logger?.ELog(args.FailureReason);
+ return -1;
+ }
+ }
+ else
+ {
+ if (args.FileService.FileMove(inputFile, dest).Failed(out string error))
+ {
+ args.FailureReason = "Failed to move file: " + error;
+ args.Logger?.ELog(args.FailureReason);
+ return -1;
+ }
+ }
if (PreserverOriginalDates)
{
@@ -198,7 +237,7 @@ public class MoveFile : Node
var result = GetDestinationPathParts(args, destinationPath, destinationFile, moveFolder);
if(result.Filename == null)
return null;
- return result.Path + result.Separator + result.Filename;
+ return FileHelper.Combine(result.Path, result.Filename);
}
///
diff --git a/FileFlows.Plugin.dll b/FileFlows.Plugin.dll
index 39652f01..96116080 100644
Binary files a/FileFlows.Plugin.dll and b/FileFlows.Plugin.dll differ
diff --git a/FileFlows.Plugin.pdb b/FileFlows.Plugin.pdb
index 79fcc822..2b1fff47 100644
Binary files a/FileFlows.Plugin.pdb and b/FileFlows.Plugin.pdb differ