How to Rename & Move Files with Spaces in Name at Command Line

  • 23 October 2022
  • 3 replies
  • 18 views

Userlevel 7

 

If you’re new to the Mac command line you may have come across a situation where you’re trying to interact with a file that has spaces in the name, for example “This File.txt” but as you probably discovered, you can’t simply type the file name if there are spaces within the file name, or the command to move, rename, copy, or otherwise interact with the file will fail to execute.

There are a few ways to interact with files from Terminal that have spaces in the file names, but one is arguably easier to remember and use than the other.

We’re focusing on the Mac here, but this works with basically any unix command line you’ll encounter, whether it’s MacOS, Linux, Windows WSL, etc.

 

★★ Full Article ★★


3 replies

Userlevel 7
Badge +4

Good article. Worth noting that if you are using the terminal app and therefore have the Finder GUI app in the background, you can drag a file or folder onto the terminal window and it will add the full path to that file/folder to save you having to type anything. 

Userlevel 7
Badge +4

Handy tip! Thank you and shared with the team

Userlevel 7
Badge +25

This is a great tip. Now, can you take it a step further and discuss how to edit names that end up with special characters in the name?

Reply