How to Rename a file using Mac Terminal

In order to rename a file using Mac Terminal make use of the mv (move) command.


Suppose I have a file name myfile.txt on the Mac Desktop and I want to rename it to myfile_2020.txt then below are the steps,

  1. Open Mac Terminal,
  2. Move to the Desktop: cd ~/Desktop
  3. Now to rename the file run the mv command,

    mv current-file-name new-file-name
    % mv myfile.txt myfile_2022.txt
  4. The file will be renamed with myfile_2022.txt
Rename file using Mac Terminal using mv Command
Before renaming the file
Before renaming the file
After renaming the file
After renaming the file

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail:

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap