diff --git a/Code/IO/IOUtils.cs b/Code/IO/IOUtils.cs
index 6945fd3..bf6e6ed 100644
--- a/Code/IO/IOUtils.cs
+++ b/Code/IO/IOUtils.cs
@@ -441,7 +441,7 @@ namespace Flowframes.IO
}
///
- /// 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.
///
public static void RenameExistingFile(string path)
{
@@ -464,6 +464,29 @@ namespace Flowframes.IO
}
}
+ ///
+ /// Add ".old" suffix to an existing folder to avoid it getting overwritten. If one already exists, it will be ".old.old" etc.
+ ///
+ 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);
+ }
+ }
+
///
/// Easily rename a file without needing to specify the full move path
///