Use of free form file names in Command Prompt


  1. Posts : 28
    Windows 7 64 bit Ultimate
       #1

    Use of free form file names in Command Prompt


    Can someone advise me how to specify files names that contains a space, e.g.

    the name "this file" in Command Prompt.

    I tried using " and ' to quote the file name, but none works

    Thanks
      My Computer


  2. Posts : 1,800
    Windows 7 Pro x64 SP1
       #2

    ffrree said:
    Can someone advise me how to specify files names that contains a space, e.g.

    the name "this file" in Command Prompt.

    I tried using " and ' to quote the file name, but none works

    Thanks
    Welcome ffrree, long file names with embedded spaces require a full set of quotes
    starting and ending with no spaces at the front or end.

    cmd "xxx readme.exe"
    if this was an executable.

    or
    c:\> copy "file1 stuff.doc" "rrr is a file name.doc"

    will work
    notice the starting and ending quotes.

    Rich
      My Computer


  3. Posts : 10,200
    MS Windows 7 Ultimate SP1 64-bit
       #3

    ffrree,

    Actually, in win 7 we do have a couple of changes.

    As an example, go to a cmd prompt and type help cd

    Here is part of what your will see:

    If Command Extensions are enabled CHDIR changes as follows:

    The current directory string is converted to use the same case as
    the on disk names. So CD C:\TEMP would actually set the current
    directory to C:\Temp if that is the case on disk.

    CHDIR command does not treat spaces as delimiters, so it is possible to
    CD into a subdirectory name that contains a space without surrounding
    the name with quotes. For example:

    cd \winnt\profiles\username\programs\start menu

    is the same as:

    cd "\winnt\profiles\username\programs\start menu"

    which is what you would have to type if extensions were disabled.

    Try it out by doing a
    cd \program files

    ===============================

    now what is the specific example which is giving you problems?
      My Computer


  4. Posts : 797
    Windows 7 Ultimate (x64)
       #4

    There are some differences depending on which command line interpreter you are using. You can check the way your system behave by using the Tab key to fill in the rest of the file name (i.e. change your working directory to C:\ and type P then press the Tab key, or type D and press the tab key: the system will type the rest of the file (or folder) name automatically provided the name is unique). Do it once and you will know for sure.

    On my PC I actively use two different prompts - the Windows command prompt and also the bash shell (powered by Cygwin). As you can see from the screnshot, the two handle spaces in the file names rather
    differently.
    Attached Thumbnails Attached Thumbnails Use of free form file names in Command Prompt-capture.png  
      My Computer


 

  Related Discussions
Our Sites
Site Links
About 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 23:09.
Find Us