How to rename files and folders on Mac using Terminal

The mv command is used for renaming files/folders. Also, it can change the location of the renamed file.

Rename the file or folder in the current working directory. Using pwd command in the terminal to check the current working directory

mv OldName newName

We have provided the full path to rename the file and folder, which is not in the current working directory.

Rename folder – mv /test/OldName /test/newName

Rename File – mv /test/product1.txt /test/product2.txt

Rename and copy the file into different locations. just provide the different location with the new file name. it will be moving the file and rename to the new path.

mv /Users/Documents/product1.txt  /Users/product/productname.txt

Leave a Comment

Your email address will not be published. Required fields are marked *