Computer Hope

Microsoft => Microsoft DOS => Topic started by: JL2 on January 24, 2021, 07:21:03 PM

Title: Help with Command-Line
Post by: JL2 on January 24, 2021, 07:21:03 PM
Hello,
new to board.

I made an error in the way I named a folder on my computer that didn't present itself a problem until recently.

The folder name structure is:   Name1 & Name2

Recently while trying to solve another issue, I needed to change to that directory using c:\cd Name1 & Name2  and that ampersand prevented me from accessing the folder because I don't know the syntax to use.

Would someone be so kind to help me please?
Title: Re: Help with Command-Line
Post by: strollin on January 25, 2021, 06:12:52 AM
Try putting the folder name in quotes like this: cd c:\"name1 & name2"
Title: Re: Help with Command-Line
Post by: JL2 on January 25, 2021, 09:05:17 AM
thank you strollin for your reply, however, that did not work.

I've also tried cd name1""^&""name2
Title: Re: Help with Command-Line
Post by: patio on January 25, 2021, 11:45:53 AM
Rename the folder with no ampersand...
Title: Re: Help with Command-Line
Post by: strollin on January 25, 2021, 11:59:44 AM
Renaming the folder as suggested by patio will also work but isn't necessary.  The quotes will work provided you typed the command correctly.  The syntax you attempted: cd name1""^&""name2, will work fine as long as you simply use quotes like: cd name1" & "name2 (don't forget the spaces before and after the ampersand).
Title: Re: Help with Command-Line
Post by: JL2 on January 27, 2021, 10:18:50 AM
thanks again for your response but I'm unable to get the result I'm looking for. I have read your instructions carefully.

I was able to find a solution on another board.

Make sure to be in the directory where your folder is located. In this case c:\users

type:  cd name
press the TAB key
result: "name & name2"
press ENTER
result: c:\Users\name & name2    You are now in the directory

Thanks again
Title: Re: Help with Command-Line
Post by: strollin on January 27, 2021, 12:45:43 PM
Glad you found a way to do it, the method I posted has worked fine for me for many years.

Another command that would work: cd c\users\Name1*
Title: Re: Help with Command-Line
Post by: Squashman on March 26, 2021, 01:28:18 PM
Best practice is to quote around the full path for any command you are using with file or folder paths.

Code: [Select]
cd "c:\name1 & name2"
Code: [Select]
cd "name1 & name2"