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 is a seasoned developer with over 10 years of experience in web and app development, and a deep knowledge of operating systems. Author of insightful How-To articles for Code2care.

Follow him on: X

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