Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Cannot change directory (CD) to a directory with space in the name

31 Aug 2013   #1

Windows 7 Pro x64
 
 
Cannot change directory (CD) to a directory with space in the name

Following the directions outlined in Change Directory in Command Prompt including enabling command extensions outlined in Command Line does not permit the CD command to change the directory focus to a directory with a space in its name. I am trying to set the active directory prompt to C:\Users\Owner\My Documents. I can get to C:\Users\Owner but with command extensions enabled in administrator mode (CMD E:ON) the CD command will not accept My Documents as a valid directory name within Owner. The error I get is "The system cannot find the path specified." My goal is to get a directory tree (as a file) of the directories and files in My Documents with the DIR command when in that directory. The complete DOS line for that command would read C:\Users\Owner\My Documents>DIR /o:n /s > DirTreeList.txt. Any help would be greatly appreciated.

My System SpecsSystem Spec
.

01 Sep 2013   #2

Microsoft Community Contributor Award Recipient

Windows 7 Home Premium x64 SP1
 
 

Welcome to Seven Forums utnatw7f387. I'm far from an expert, but will throw out something simple until the smart people see this. have you tried

C:\Users\Owner\My\ Documents>DIR /o:n /s > DirTreeList.txt

A Guy
My System SpecsSystem Spec
01 Sep 2013   #3

Windows 7 Pro x64
 
 

Guy, I tried your suggestion just to see if the directory focus could be changed to My Documents, but I get the same error mentioned originally. Starting at C:> I can get to C:\Users\Owner> But the CD command cannot find the specified path when I try C:\Users\Owner>cd My\ Documents. Thank you for your suggestion, it was certainly worth a try. Freedom of wind in the face and ears a-flapping - Great sig.
My System SpecsSystem Spec
.


01 Sep 2013   #4

Win 7 Pro x64 SP1, Win 7 Ult x86 SP1
 
 

Try this command:
DIR C:\Users\Owner\Documents /o:n /s > DirTreeList.txt
My System SpecsSystem Spec
01 Sep 2013   #5

Windows 7 Pro x64
 
 

Thank you David, that WORKED! I successfully got the directory list I was after. I will document this solution so I never lose it. Thanks again to you both. I have marked the problem as solved.
My System SpecsSystem Spec
01 Sep 2013   #6

Win 7 Pro x64 SP1, Win 7 Ult x86 SP1
 
 

You're welcome!
Glad you got it solved.
My System SpecsSystem Spec
01 Sep 2013   #7

Microsoft Community Contributor Award Recipient

Windows 7 Home Premium x64 SP1
 
 

Good one David. I considered that, but the whole library thing confuses me Glad you got it sorted utnatw7f387. A Guy
My System SpecsSystem Spec
01 Sep 2013   #8

Windows 7 Pro x64
 
 

I checked and found this solution works for all User directories beginning with My. I also checked to see if it worked for User directory names like Saved Games, Start Menu, & Virtual Machines. In those cases, the full name with the space is accepted by the CD command. There is nothing quite as nice as consistency and adequate documentation of odd features, is there? I don't have a need for directory lists for system directories not related to a user, but it would be nice to know if this solution will work in those cases, too. Thanks again to both of you, you saved my day. Any further thoughts guys?
My System SpecsSystem Spec
01 Sep 2013   #9

Win 7 Pro x64 SP1, Win 7 Ult x86 SP1
 
 

The problem is with Win 7 "My Documents" is a Junction Point, and the directory (folder) name is Documents.
Yup, it makes it confusing because you see "My Documents" in Windows Explorer.
But, if you do a DIR command in a CMD window you will see "Documents" as the folder name in your User directory.
My System SpecsSystem Spec
01 Sep 2013   #10

Windows 7 Pro x64
 
 

Thanks Dave, I think that clears this up quite a bit. In the meantime I checked some other directory names with spaces and the CD command accepts them all. I hate to keep asking questions, but are there other Junction Point situations other than those we see as My ...?
BTW are you aware of this odd but useful undocumented feature?
The "Include subfolders in search results..." switch in WE Tools > Folder Options > Search > How to search behaves differently for the two My Documents access points. Searches under Desktop > Libraries > Documents > My Documents always searches all sub-folders independent of this switch. That's probably a good idea for users who have no idea where their lost files might be. But, searches in C:\Users\Owner\Documents respond to the switch setting. That's kind of handy if you have a better idea of where your lost files might be located. Accident or deliberate, it's kind of a neat feature to know about.
My System SpecsSystem Spec
Reply

 Cannot change directory (CD) to a directory with space in the name




Thread Tools



Similar help and support threads for2: Cannot change directory (CD) to a directory with space in the name
Thread Forum
Change the default directory in the explorer. Customization
File directory: Many directory bear the same name after hd replacement Performance & Maintenance
Solved Change Recorded TV Directory without WMC Customization
Solved Change Directory in Command Prompt General Discussion
Replace files in multiple directory, from a single directory General Discussion
How to change LOCATION of a directory in Win 7 Installation & Setup
[ask] can i change directory for my theme Themes and Styles

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd

All times are GMT -5. The time now is 11:13 PM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33