1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Command line questions

Discussion in 'A+' started by mikehende, Jun 28, 2006.

  1. mikehende

    mikehende Kilobyte Poster

    265
    0
    19
    I'm on page 572 "Directories: The CD Command"

    I am not getting DOS to point to any directories, following MM's example, I type
    C:\Temp

    and I get this message:
    'C:\Temp' is not recognized as an internal or external command, operable program or batch file.

    Any ideas why it doesn't point me to the directory?
     
  2. Mr.Cheeks

    Mr.Cheeks 1st ever Gold Member! Gold Member

    5,369
    85
    190
    in CMD you type CD TEMP

    C:\TEMP is the "folder" you are in
     
  3. hbroomhall

    hbroomhall Petabyte Poster Gold Member

    6,623
    115
    224
    I don't have the book in front of me - I'd have to wait until I get home - but the command to *change directory* to \temp would be
    Code:
    cd \temp
    Harry.
     
    Certifications: ECDL A+ Network+ i-Net+
    WIP: Server+
  4. simongrahamuk
    Honorary Member

    simongrahamuk Hmmmmmmm?

    6,199
    125
    199
    Would it not simply be:

    Code:
    cd temp
    Why the backslash Harry?
     
  5. mikehende

    mikehende Kilobyte Poster

    265
    0
    19
    ok, it works! I can now change to any directory and list it's contents, stay tuned, thanks.
     
  6. d-Faktor
    Honorary Member

    d-Faktor R.I.P - gone but never forgotten.

    810
    0
    39
    to indicate that it needs to start in root. how very x.

    [edit] apologies to harry for cutting in line.
     
  7. hbroomhall

    hbroomhall Petabyte Poster Gold Member

    6,623
    115
    224
    To expand a bit on d-Faktor's answer:

    I said
    . Note the backslash there to indicate that the temp directory exists in the root of the drive. Hence including it in the CD command.

    Obviously if the temp directory was a subdirectory of where I was then the backslash shouldn't be used.

    Harry.
     
    Certifications: ECDL A+ Network+ i-Net+
    WIP: Server+
  8. Mr.Cheeks

    Mr.Cheeks 1st ever Gold Member! Gold Member

    5,369
    85
    190
    now thats precise! i never thought of it that way :thumbleft
     
  9. ffreeloader

    ffreeloader Terabyte Poster

    3,661
    106
    167
    Well, that slash isn't even necessary in *nix. If you're in / and want to change to /home it is "cd home". If you're moving to a user's home directory from / it would be "cd home/username". You don't need an absolute path if the first directory you are moving to or beyond is a direct subdirectory.

    Absolute paths are unnecessary in DOS under the same circumstances that they are unnecessary in *nix.
     
    Certifications: MCSE, MCDBA, CCNA, A+
    WIP: LPIC 1
  10. hbroomhall

    hbroomhall Petabyte Poster Gold Member

    6,623
    115
    224
    Generalizing further - a 'pathname' can be either absolute or relative.

    Absolute would be \temp - you are describing where it is relative to root.

    Relative would be things like 'temp' and ..\temp - you are describing where it is relative to where you are.

    *nix is the same - just use / instead of \

    Harry.
     
    Certifications: ECDL A+ Network+ i-Net+
    WIP: Server+
  11. d-Faktor
    Honorary Member

    d-Faktor R.I.P - gone but never forgotten.

    810
    0
    39
    this is about efficiency, not necessity.

    if you are in c:\folder1\subfolder\subfolder\subfolder, you can quickly go to c:\folder2 by using cd \folder2. sure, you can accomplish the same by doing a cd c:\folder2, but that can be inefficient if you need to dispose of drive letters in your script. or you can do a
    cd \
    cd folder2
    , which can be inefficient if you need to have a lot of these in a script.

    and how did unix get into this discussion? i guess my x pun was misinterpreted. and i hate explaining jokes, so i'll leave just it at that.
     
  12. ffreeloader

    ffreeloader Terabyte Poster

    3,661
    106
    167
    LOL. Sorry, you know I'll work *nix into any discussion.... :twisted:

    Actually, I thought you were referring to *nix with the 'x' you used....
     
    Certifications: MCSE, MCDBA, CCNA, A+
    WIP: LPIC 1
  13. mikehende

    mikehende Kilobyte Poster

    265
    0
    19
    2 questions:

    1] When typing the names of the folder, is this case-sensitive?

    2] When typing folders that have 2 or more words with spaces in between them do I now have to type the names of the folders [directories]with or without the spaces?

    I am trying to work with the different methods above and I am not getting a consistent outcome which is why I am asking.
     
  14. ffreeloader

    ffreeloader Terabyte Poster

    3,661
    106
    167
    DOS is not case sensitive.

    If the file names or folder names have spaces you have to put the entire path in double quotes.
     
    Certifications: MCSE, MCDBA, CCNA, A+
    WIP: LPIC 1
  15. mikehende

    mikehende Kilobyte Poster

    265
    0
    19
    Thanks, I am not getting the idea behind the "double quotes" though. Let's say I wish to change directory from
    c:\temp

    to a folder on my C drive with the name Music Tools, I can do this by typing
    cd\music tools

    how would I use double quotations to make this change?
     
  16. hbroomhall

    hbroomhall Petabyte Poster Gold Member

    6,623
    115
    224
    Code:
    cd "\Music Tools"
    Harry.
     
    Certifications: ECDL A+ Network+ i-Net+
    WIP: Server+
  17. mikehende

    mikehende Kilobyte Poster

    265
    0
    19
    works but I don't understand this, why is the backslash still there if you use a space after cd?
     
  18. hbroomhall

    hbroomhall Petabyte Poster Gold Member

    6,623
    115
    224
    The backslash is to indicate that this is an absolute path. Without it you are assuming the folder is a subdirectory of where you are.

    Harry.
     
    Certifications: ECDL A+ Network+ i-Net+
    WIP: Server+
  19. mikehende

    mikehende Kilobyte Poster

    265
    0
    19
    Thanks, now I also know for the first time what an "absolute" path is :D .

    Next, concerning using the space instead of the backslash, I am not getting this to work, if I am at
    c:\windows

    and wish to go to c:\temp without using the slash, how would I write this please?
     
  20. ffreeloader

    ffreeloader Terabyte Poster

    3,661
    106
    167
    As c:\temp and c:\windows are obviously both folders that reside on the root folder c:\ but neither are subfolders of the other, you must use the absolute path.
     
    Certifications: MCSE, MCDBA, CCNA, A+
    WIP: LPIC 1

Share This Page

Loading...