Ruby - Renaming and Deleting Files

Introduction

To change the name of a file, use File.rename like so:

File.rename("file1.txt", "file2.txt") 

You can delete either one file at a time or many at once:

File.delete("file1.txt") 
File.delete("file2.txt", "file3.txt", "file4.txt") 
File.unlink("file1.txt") 

File.unlink does exactly the same thing as File.delete.

Related Topic