Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

cd-ing to a directory with a lot of spaces--mac terminal

Writer Matthew Martinez

I want to cd to a path with spaces in the folder names, but it doesn't work. I want to navigate straight to a directory which has multiple levels of directories on the way, each with a lot of spaces. Please look at the following example:

Say I want to navigate to:

./Folder/Animal Pictures/Dog Pictures/Golden Retriever Pictures/Golden Retrievers Playing Ball

I tried:

cd ./Folder/"Animal Pictures"/"Dog Pictures"/"Golden Retriever Pictures"/"Golden Retrievers Playing Ball"

But I got the error:

cd: too many arguments

What should I do?

4

1 Answer

You use a backslash to indicate the next character is part of the name & not a split where a new instruction starts.

cd ./Folder/Animal\ Pictures/Dog\ Pictures/Golden\ Retriever Pictures/Golden\ Retrievers\ Playing\ Ball

You can test this - or even use it to be much quicker than typing, by just typing cd then dragging the folder itself from Finder to Terminal. It will format it correctly for you.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy