Also add ".old" to image sequence outputs if folder already exists

This commit is contained in:
N00MKRAD
2021-05-17 21:12:09 +02:00
parent 6b99551619
commit 9f9efaf95f

View File

@@ -441,7 +441,7 @@ namespace Flowframes.IO
}
/// <summary>
/// Add ".old" suffix to existing files to avoid them being overwritten. If one already exists, it will be ".old.old" etc.
/// Add ".old" suffix to an existing file to avoid it getting overwritten. If one already exists, it will be ".old.old" etc.
/// </summary>
public static void RenameExistingFile(string path)
{
@@ -464,6 +464,29 @@ namespace Flowframes.IO
}
}
/// <summary>
/// Add ".old" suffix to an existing folder to avoid it getting overwritten. If one already exists, it will be ".old.old" etc.
/// </summary>
public static void RenameExistingFolder(string path)
{
if (!Directory.Exists(path))
return;
try
{
string renamedPath = path;
while (Directory.Exists(renamedPath))
renamedPath += ".old";
Directory.Move(path, renamedPath);
}
catch (Exception e)
{
Logger.Log($"RenameExistingFolder: Failed to rename '{path}': {e.Message}", true);
}
}
/// <summary>
/// Easily rename a file without needing to specify the full move path
/// </summary>