Skip to content

Try our new Crash Courses!

Buy one of our new Crash Courses, now hosted on Podia.

Rename file or folder – Terminal

Summary

To rename a folder or file using your terminal, enter the following command:

mv current-name new-name

Warning

If there is already a file named new-name, the above command will overwrite it with the contents of current-name, and you will lose what was inside the original new-name file. Use the mv command with caution.

Details

Examples

If you had a file named index.html that you wanted to rename about.html, you would enter the following command in your terminal:

mv index.html about.html

If the files were in a subfolder called public, you would include the folder path in your command:

mv public/index.html public/about.html

If you had a folder named folder1 that you wanted to rename folder2, you would enter the following command in your terminal:

mv folder1 folder2

Exercises

Try the following command in your project folder:

mv css/main.css css/style.css

References

Command Line Primer on the Apple Developer Archive (see the section called Frequently Used Commands)

Back to: Terminal Reference > Terminal Advanced Commands