Free Perl Tutorials

How To Rename A File In PERL

Renaming a file in PERL couldn't be easier, and here is a tutorial on how to rename a file using PERL programming code.

1) Create a text file in your C:/Test folder called "test.txt" If you would like to test your programming skills you can create this file without the help of notepad by using your newfound PERL programming skills! (Need to develop those skills, visit our how to create a file using PERL tutorial)
2) So I'll assume you've created a file called "test.txt" now hopefully using your PERL programming skills! Here is the code to rename a file in PERL:

rename "test.txt", "test-hooray-it-works.txt"

3) Save the file as "t.pl"
4) Run the file from your command prompt.
5) Check your file, and it should be renamed!

Thats how easy it is to rename a file using PERL!

If it didn't work, you probably didn't have the "t.pl" and "test.txt" files in the same folder?