Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Silly Question On The Command Prompt Tutorial


  • Please log in to reply
13 replies to this topic

#1 BanditFlyer

BanditFlyer

  • Members
  • 283 posts
  • OFFLINE
  •  
  • Local time:04:03 PM

Posted 18 November 2005 - 11:21 AM

How do you cd to a directory with a space in the name?

such as "Program Files"

I know I've seen something explaining how to do this somewhere on the net before...

Here are some futile tries from my PC:

11/15/2005 09:10 AM <DIR> Program Files
06/01/2005 02:34 PM 164 psswd.pl
05/16/2005 03:43 PM <DIR> PVSW
05/16/2005 01:37 PM <DIR> pvswarch
04/18/2005 07:44 AM <DIR> REPORTS
10/14/2005 08:25 AM 1,847 SASIAPP_PDFTypewriter.pdf
03/10/2005 02:36 PM <DIR> sj664
02/18/2005 12:03 PM 80,426,496 sj664en.exe
11/15/2005 11:47 AM <DIR> WINDOWS
02/17/2005 03:13 PM <DIR> WUTemp
15 File(s) 80,571,947 bytes
17 Dir(s) 26,760,187,904 bytes free

C:\>cd Program Files
Too many parameters - Files

C:\>cd "Program Files"
Parameter format not correct - "Program

C:\>cd PROGRA~8
Invalid directory

C:\>cd PROG~8
Invalid directory

C:\>cd /?
Displays the name of or changes the current directory.

CHDIR [drive:][path]
CHDIR[..]
CD [drive:][path]
CD[..]

.. Specifies that you want to change to the parent directory.

Type CD drive: to display the current directory in the specified drive.
Type CD without parameters to display the current drive and directory.

C:\>

BC AdBot (Login to Remove)

 


#2 BanditFlyer

BanditFlyer
  • Topic Starter

  • Members
  • 283 posts
  • OFFLINE
  •  
  • Local time:04:03 PM

Posted 18 November 2005 - 11:34 AM

Gettin' closer:


C:\>cd \"Program Files\"
Too many parameters - Program

C:\>

#3 Leurgy

Leurgy

    Voted most likely


  • Members
  • 3,831 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Collingwood, Ontario, Canada
  • Local time:07:03 PM

Posted 18 November 2005 - 11:44 AM

When you are working in Dos, File and Directory names are limited to 8 characters. Since there may be more than one File or Directory with the same name the names are truncated to include the tilde sign (~) and a number. Thus, Program Files becomes Progra~1.

At, say, C:\Windows> to return to the root of C: type the following:

C:\Windows>cd \

brings you to C:\>

Then to see all the files and directories on C: type the following:

C:\>dir /w

The /w switch allows everything to be displayed in a wide format so it is visible on one screen. This will show the truncated names so you can change to the directory you want. You can also use the /p switch so the files and directories are display page by page.

Edited by Leurgy, 18 November 2005 - 11:52 AM.

When the only tool you own is a hammer, every problem begins to resemble a nail. Abraham Maslo

**** We use our powers for good, not evil ****

 Trying to remove your data from the web is like trying to remove pee from a swimming pool


#4 Joshuacat

Joshuacat

    01001010 01000011


  • Members
  • 1,950 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Ontario, Canada
  • Local time:08:03 PM

Posted 18 November 2005 - 11:45 AM

cd program files

Works on my computer. I am using Windows 2000, and using the dos prompt through the windows interface.
JC

#5 BanditFlyer

BanditFlyer
  • Topic Starter

  • Members
  • 283 posts
  • OFFLINE
  •  
  • Local time:04:03 PM

Posted 18 November 2005 - 11:46 AM

BINGO!!!!!

This might not work for you - it probably depends on your file system - might be different for NTFS, FAT32, FAT16....


C:\>cd Progra!1
Invalid directory

C:\>cd Progra~1

C:\PROGRA~1>dir
Volume in drive C has no label.
Volume Serial Number is 5CBB-1DFE

Directory of C:\PROGRA~1

11/15/2005 09:10 AM <DIR> .
11/15/2005 09:10 AM <DIR> ..
09/13/2005 08:52 AM <DIR> Acro Software
08/12/2005 12:37 PM <DIR> Acrobat Reader 5
08/16/2005 04:33 PM <DIR> Adobe


Might want to add that to the dos command prompt tutorial.

Other things I have seen on the net are to try to put quotes around the directory name, try to put escaped quotes aroundthe directory name, use the directory name as an argument with the / flag

You can see in previous posts that I tried those and they didn't work for me. (I'm on Win XP.)

Back to work - honestly, I don't have too much time on my hands, I was just looking into dos settings becaus of an annoyance one of my users has with his command prompt window not fully expanding when he hits alt + enter...

#6 BanditFlyer

BanditFlyer
  • Topic Starter

  • Members
  • 283 posts
  • OFFLINE
  •  
  • Local time:04:03 PM

Posted 18 November 2005 - 11:50 AM

Thanks Leurgy,

Believe it or not, I came up with that answer independantly. Sorry, I was too preocupied with my command prompt and google search that I didn't read responses to my question before I posted my replies.

Thank you for your help. At least now we have a record of what works with what OSs in the bleepingcomputer forums. It'll be easy to find next time I forget how it works!!!! ;)

Edited by BanditFlyer, 18 November 2005 - 11:52 AM.


#7 Leurgy

Leurgy

    Voted most likely


  • Members
  • 3,831 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Collingwood, Ontario, Canada
  • Local time:07:03 PM

Posted 18 November 2005 - 11:56 AM

I edited my first response.

This might not work for you - it probably depends on your file system - might be different for NTFS, FAT32, FAT16....


Actually it depends on the underlying version of Dos in the OS you are using. To determine the version of Dos, boot to Command Prompt Only using F8 and at C:\> type in ver

When the only tool you own is a hammer, every problem begins to resemble a nail. Abraham Maslo

**** We use our powers for good, not evil ****

 Trying to remove your data from the web is like trying to remove pee from a swimming pool


#8 BanditFlyer

BanditFlyer
  • Topic Starter

  • Members
  • 283 posts
  • OFFLINE
  •  
  • Local time:04:03 PM

Posted 18 November 2005 - 12:00 PM

At, say, C:\Windows> to return to the root of C: type the following:

C:\Windows>cd \

brings you to C:\>

Then to see all the files and directories on C: type the following:

C:\>dir /w

The /w switch allows everything to be displayed in a wide format so it is visible on one screen. This will show the truncated names so you can change to the directory you want. You can also use the /p switch so the files and directories are display page by page.

I didn't know about \ (same as unix / )
I didn't know about /w
I didn't know about /p (similar to the pipe command | - hit shift and the \ key)

guess I should've read "dir /? " :D

Thanks

Edited by BanditFlyer, 18 November 2005 - 12:00 PM.


#9 BanditFlyer

BanditFlyer
  • Topic Starter

  • Members
  • 283 posts
  • OFFLINE
  •  
  • Local time:04:03 PM

Posted 18 November 2005 - 12:07 PM

I edited my first response.

This might not work for you - it probably depends on your file system - might be different for NTFS, FAT32, FAT16....


Actually it depends on the underlying version of Dos in the OS you are using. To determine the version of Dos, boot to Command Prompt Only using F8 and at C:\> type in ver

I'll have to check whenever I get time enough to reboot:

C:\PROGRA~1>ver

Microsoft Windows XP [Version 5.1.2600]

C:\PROGRA~1>ver /?
Displays the Windows XP version.

VER

C:\PROGRA~1>type in ver
The system cannot find the file specified.
Error occurred while processing: in.
The system cannot find the file specified.
Error occurred while processing: ver.

C:\PROGRA~1>type
The syntax of the command is incorrect.

C:\PROGRA~1>type ?/
The syntax of the command is incorrect.

C:\PROGRA~1>type/?
Displays the contents of a text file or files.

TYPE [drive:][path]filename

C:\PROGRA~1>type /?
Displays the contents of a text file or files.

TYPE [drive:][path]filename

C:\PROGRA~1>type ver
The system cannot find the file specified.

C:\PROGRA~1>type in
The system cannot find the file specified.

C:\PROGRA~1>


Thanks for the info.

#10 Leurgy

Leurgy

    Voted most likely


  • Members
  • 3,831 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Collingwood, Ontario, Canada
  • Local time:07:03 PM

Posted 18 November 2005 - 12:10 PM

If you have booted into Windows ver gives the Windows version. Thats why you need to boot to a Command Prompt Only, which only loads Dos, to use ver to see the Dos version.

When the only tool you own is a hammer, every problem begins to resemble a nail. Abraham Maslo

**** We use our powers for good, not evil ****

 Trying to remove your data from the web is like trying to remove pee from a swimming pool


#11 Joshuacat

Joshuacat

    01001010 01000011


  • Members
  • 1,950 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Ontario, Canada
  • Local time:08:03 PM

Posted 18 November 2005 - 01:38 PM

You still should be able to use the long file name.
Are you sure you are using cmd instead of the older command for your prompt.

This article explains it better than I can.

Command VS CMD

Click Start, Run, Cmd
Click OK
JC

#12 BanditFlyer

BanditFlyer
  • Topic Starter

  • Members
  • 283 posts
  • OFFLINE
  •  
  • Local time:04:03 PM

Posted 18 November 2005 - 01:59 PM

© Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\peters>cd ..\

C:\Documents and Settings>cd ..

C:\>cd program files

C:\Program Files>


You're right JoshuaCat! It works.

I always use command rather than cmd - old habit I guess...

#13 Joshuacat

Joshuacat

    01001010 01000011


  • Members
  • 1,950 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Ontario, Canada
  • Local time:08:03 PM

Posted 18 November 2005 - 02:17 PM

Great! Thanks for letting us know.
JC

#14 Leurgy

Leurgy

    Voted most likely


  • Members
  • 3,831 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Collingwood, Ontario, Canada
  • Local time:07:03 PM

Posted 19 November 2005 - 06:30 AM

Thanks for posting that Joshuacat. Like BanditFlyer I use command too. My training was Dos 6.2 which is probably the most complete and powerful version but it didn't include the cmd function so I've learned something new. :thumbsup:

When the only tool you own is a hammer, every problem begins to resemble a nail. Abraham Maslo

**** We use our powers for good, not evil ****

 Trying to remove your data from the web is like trying to remove pee from a swimming pool





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users