• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

TheMacBeginner

Mac tips, tricks and guides

  • Home
  • Mac Guides
  • Hide & unhide Dock
  • Resize Finder

Rename files and folders on Mac using Terminal

By Chaitanya | Filed Under: Mac

In my previous guide, I have shared four methods of renaming a file or a folder, in that guide I have discussed a little bit about renaming via command line. In this guide, we will discuss it in detail. The command we will use for this is: mv. The mv command not only renames your file/folder, it can change the location of your renamed file if you wish to do so.

Let’s get familiar with the syntax of mv command first:
If the file or folder you want to rename is in the current working directory(to check your current working directory just type pwd on terminal and hit return):

mv old-folder-name new-folder-name

If the file or folder you wish to rename is not in the current working directory then you need to provide the full file name.

mv /full-path/old-folder-name /full-path/new-folder-name

Renaming a file via command line

Steps are as follows:

1. Type mv then open Finder and drag the file on terminal (this is to copy the full path of file to the terminal)
Note: Please do note that while dragging the file to terminal, make sure that the finder window and terminal window don’t overlap else this trick won’t work.

2. Now you need to give the new file name, here you have two options based on where you want your new file to be. If you want your new file at the same location then type the same full path (or you can drag the file again and just edit the file name) with the new file name. The full command will look like this:

mv /Users/chaitanyasingh/Documents/TheMacBeginner/MyFile2.txt
/Users/chaitanyasingh/Documents/TheMacBeginner/MyNewFile.txt

command line rename file folder

If you want your renamed file at different location then instead of copying the same full path again just type the new file path with file name. This operation will change the file name as well as change the location of your file.
For example:

mv /Users/chaitanyasingh/Documents/TheMacBeginner/MyFile2.txt
/Users/chaitanyasingh/Documents/MyNewFile.txt

Now the renamed file would be moved from TheMacBeginner folder to the Documents folder.

Related Posts

  • Top 25 Text keyboard shortcuts on Mac everyone should know
  • Open Current working directory in Finder from Terminal – Mac OS X
  • How to Add a Folder to the Favorites in the Finder sidebar?
  • Activity Monitor: Mac Task Manager
  • How to change Screen Capture File Format on Mac OS

Reader Interactions

Leave a Reply Cancel reply

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

Primary Sidebar

Search this Website

Featured Mac Guides

How to Exit Full Screen in Mac OS X

How to hide and unhide the Dock on Mac

How to Change the Position of Dock on your screen

Remove Applications from the Dock on Mac

How to switch between different windows of same Application

How to switch between Open Applications in Mac OS X

Copyright © 2017 - 2019 TheMacBeginner - All Rights Reserved || Sitemap