Lean 4 (Meta)programming Cookbook

Renaming a file path🔗

To rename a file path, you can use the IO.FS.rename function, which takes the old path and the new path as arguments.

def renameFile (oldPath newPath : System.FilePath) : IO Unit := do try IO.FS.rename oldPath newPath IO.println s!"Renamed {oldPath} to {newPath}" catch e => IO.eprintln s!"Failed to rename {oldPath} to {newPath}: Error Found: {e}"