Rename a file or directory

Verified
Added by iNTERFACEWARE

Use os.fs.rename() to rename a file or directory, if the file or directory does not exist an error is returned

Source Code
   -- create and create and rename a directory
   os.fs.mkdir('MyTempDir')
   os.fs.stat('MyTempDir')
   
   -- rename the directory
   os.rename('MyTempDir','YourTempDir')
   
   os.fs.stat('MyTempDir') -- stats no longer available
   os.remove('YourTempDir')
Description
Use os.fs.rename() to rename a file or directory, if the file or directory does not exist an error is returned
Usage Details

Use os.fs.rename() to rename a file or directory. If the file or directory does not exist then an error is returned.

How to use the snippet:

  • Paste the code into your script