To rename a folder on Windows, select it in File Explorer, press F2, type the new name, and press Enter. On a Mac, select it in Finder and press Return instead; in a terminal on Linux or Mac, run mv old-folder new-folder.
This article covers each system, the command-line versions, and the folders you should leave alone. The steps for a folder are the same as for a file, so if you also need to rename files, see how to rename a file on Windows, Mac and Linux, which also covers renaming many files at once.
How to rename a folder on Windows
In File Explorer:
- Select the folder and press F2. Microsoft's shortcut list describes F2 as "Rename the selected item."
- Or right-click the folder and choose Rename. In Windows 11 the Rename option is one of the icons at the top of the right-click menu.
- Type the new name and press Enter.
Rename a folder in Command Prompt
The rename command (also ren) renames directories as well as files. Microsoft's own example changes a directory from Chap10 to Part10:
rename chap10 part10
Quote names that contain spaces:
ren "old folder" "new folder"
Per Microsoft's documentation, you can't give a new drive or path as the new name, and the command can't move items to another directory. The new name must be unique: if it matches an existing name, you get Duplicate file name or file not found.
Rename a folder in PowerShell
Rename-Item (aliases ren and rni) takes the current path and the new name only:
Rename-Item -Path "C:\work\old-folder" -NewName "new-folder"
If you put a different path in -NewName, PowerShell refuses. The documented example error is "can't rename because the target specified represents a path or device name". To rename and move together, use Move-Item. Rename-Item also won't replace an existing item, even with -Force. Add -WhatIf to preview the change without running it.
How to rename a folder on a Mac
Apple's steps for a folder in Finder:
- Select the folder, then press Return (or force click its name).
- Type the new name.
- Press Return again.
macOS does not allow a colon (:) in a name, and a name can't begin with a period. Apple also notes that some apps don't allow a slash (/) in a file name.
Folders you should not rename on a Mac
Apple's guidance:
- Don't rename app folders or system items, such as the Library folder.
- Don't rename your home folder, the one with your name on it.
If renaming causes problems, Apple says to change the name back, and if that doesn't help you may need to reinstall the software. Most disks, including the internal disk (named Macintosh HD by default), can be renamed.
How to rename a folder on Linux (and in the Mac Terminal)
On Linux, renaming is a move to a new name in the same location:
mv old-folder new-folder
The mv manual page describes it as "Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY." Quote names with spaces:
mv "old folder" "new folder"
Check that the new name is not already a folder. The manual's second form, mv SOURCE... DIRECTORY, moves sources into a directory. So if new-folder already exists as a directory, the page's synopsis implies that old-folder ends up inside it rather than being renamed (the page does not spell this case out). To make mv treat the destination as a normal name instead, use -T (--no-target-directory), which the manual describes as "treat DEST as a normal file":
mv -T old-folder new-folder
Linux names are case sensitive, so Photos and photos are different folders. For other everyday commands, see basic Linux commands.
Why you can't rename a folder
- The name already exists. Command Prompt reports
Duplicate file name or file not found, andRename-Itemwill not replace an existing item. Choose another name. - The name uses a character the system rejects. A colon is not permitted on a Mac, and a name can't start with a period there.
- You are trying to rename and move together on Windows. Both
renameandRename-Itemtake a new name only. UseMove-Itemfor a different location. - The folder is hidden or read-only (PowerShell). Microsoft says
-ForceletsRename-Itemrename such items, though it can't override security restrictions.
If you renamed a folder by mistake, rename it back to the original name.
Frequently asked questions
- What is the shortcut to rename a folder?
- On Windows, select the folder in File Explorer and press F2. On a Mac, select it in Finder and press Return. Type the new name and confirm with Enter (Windows) or Return (Mac).
- Does renaming a folder change the files inside it?
- No. Rename-Item, for example, changes the name of the item and does not affect its content. The files inside keep their names, but their full paths now start with the new folder name.
- Can I rename a folder and move it in one command?
- Not with ren or Rename-Item. Command Prompt's rename cannot move items to another directory, and Rename-Item accepts a name only. Use Move-Item in PowerShell, or mv on Linux and Mac, which can rename and move at once.
- What should I not rename on a Mac?
- Apple advises against renaming app folders, system items such as the Library folder, and your home folder. If a rename causes problems, change the name back.