Space in 'My Documents' directory not fixed by quoting or \ escaping

Discussion in 'Java' started by bilsch, May 29, 2012.

  1. bilsch

    bilsch Guest

    I'm writing a DOS script that uses pathnames with the well known Windows
    directory 'My Documents'. The name has a space in it that causes javac
    and java commands to choke. Neither of the following works:
    'My Documents' (single quotes) or My\ Documents (escape the space).
    Here is an example:

    javac -d C:/Users/Owner/'My Documents'/NetBeansProjects/%1/build/classes

    Can anyone tell me the workaround for this?

    TIA Bill S.
    bilsch, May 29, 2012
    #1
    1. Advertising

  2. On 05/29/2012 02:16 PM, bilsch wrote:
    > I'm writing a DOS script that uses pathnames with the well known Windows
    > directory 'My Documents'. The name has a space in it that causes javac
    > and java commands to choke. Neither of the following works:
    > 'My Documents' (single quotes) or My\ Documents (escape the space).
    > Here is an example:
    >
    > javac -d C:/Users/Owner/'My Documents'/NetBeansProjects/%1/build/classes
    >
    > Can anyone tell me the workaround for this?
    >
    > TIA Bill S.


    Not really Java related but anyway: in DOS/Windows you need to quote the
    complete path like "C:/My Documents/Pictures/abc.WMV" etc.

    Silvio
    Silvio Bierman, May 29, 2012
    #2
    1. Advertising

  3. bilsch

    Nigel Wade Guest

    On 29/05/12 13:32, Silvio Bierman wrote:
    > On 05/29/2012 02:16 PM, bilsch wrote:
    >> I'm writing a DOS script that uses pathnames with the well known Windows
    >> directory 'My Documents'. The name has a space in it that causes javac
    >> and java commands to choke. Neither of the following works:
    >> 'My Documents' (single quotes) or My\ Documents (escape the space).
    >> Here is an example:
    >>
    >> javac -d C:/Users/Owner/'My Documents'/NetBeansProjects/%1/build/classes
    >>
    >> Can anyone tell me the workaround for this?
    >>
    >> TIA Bill S.

    >
    > Not really Java related but anyway: in DOS/Windows you need to quote the
    > complete path like "C:/My Documents/Pictures/abc.WMV" etc.
    >


    it's often very convenient to use tab expansion of paths (both in
    Windows cmd shell, and UNIX/Linux bash shell). This would have
    discovered the correct path for the OP. For example, enter in the cmd.exe:

    javac -d C:\Users\Owner\My

    then hit tab. Windows will do the rest, even adding appropriate quotes
    where necessary. Note that you must use the Windows \ path separator for
    this to work.

    --
    Nigel Wade
    Nigel Wade, May 29, 2012
    #3
  4. bilsch

    Lew Guest

    Nigel Wade wrote:
    > Silvio Bierman wrote:
    >> bilsch wrote:
    >>> I'm writing a DOS script that uses pathnames with the well known Windows
    >>> directory 'My Documents'. The name has a space in it that causes javac
    >>> and java commands to choke. Neither of the following works:
    >>> 'My Documents' (single quotes) or My\ Documents (escape the space).
    >>> Here is an example:
    >>>
    >>> javac -d C:/Users/Owner/'My Documents'/NetBeansProjects/%1/build/classes
    >>>
    >>> Can anyone tell me the workaround for this?
    >>>
    >>> TIA Bill S.

    >>
    >> Not really Java related but anyway: in DOS/Windows you need to quote the
    >> complete path like "C:/My Documents/Pictures/abc.WMV" etc.
    >>

    >
    > it's often very convenient to use tab expansion of paths (both in Windows cmd
    > shell, and UNIX/Linux bash shell). This would have discovered the correct path
    > for the OP. For example, enter in the cmd.exe:
    >
    > javac -d C:\Users\Owner\My
    >
    > then hit tab. Windows will do the rest, even adding appropriate quotes where
    > necessary. Note that you must use the Windows \ path separator for this to work.


    "/" is a Windows path *element* separator. ";" is the path separator in Windows.

    Windows is fine with forward slashes in paths. I suspect the "%1" expansion.

    --
    Lew
    Honi soit qui mal y pense.
    http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg
    Lew, May 29, 2012
    #4
  5. "bilsch" <> wrote in message
    news:jq2eme$o07$...
    > I'm writing a DOS script that uses pathnames with the well known Windows
    > directory 'My Documents'. The name has a space in it that causes javac and
    > java commands to choke. Neither of the following works:
    > 'My Documents' (single quotes) or My\ Documents (escape the space).
    > Here is an example:
    >
    > javac -d C:/Users/Owner/'My Documents'/NetBeansProjects/%1/build/classes
    >
    > Can anyone tell me the workaround for this?

    Two things to try:

    1. Use double-quotes instead of single ones.
    2. Use "dir /x" to discover the short name for "My Documents" (I'd guess
    it's MYDOCU~1) and use that instead.
    Mike Schilling, May 29, 2012
    #5
  6. On Tue, 29 May 2012 07:06:31 -0700, Lew <> wrote:

    >Nigel Wade wrote:


    [snip]

    >> it's often very convenient to use tab expansion of paths (both in Windows cmd
    >> shell, and UNIX/Linux bash shell). This would have discovered the correct path
    >> for the OP. For example, enter in the cmd.exe:
    >>
    >> javac -d C:\Users\Owner\My
    >>
    >> then hit tab. Windows will do the rest, even adding appropriate quotes where
    >> necessary. Note that you must use the Windows \ path separator for this to work.

    >
    >"/" is a Windows path *element* separator. ";" is the path separator in Windows.
    >
    >Windows is fine with forward slashes in paths. I suspect the "%1" expansion.


    But since using "/" as a path element seprator in a command line
    will cause trouble, people tend to avoid using them as such.

    Sincerely,

    Gene Wirchenko
    Gene Wirchenko, May 29, 2012
    #6
  7. bilsch

    bilsch Guest

    On 5/29/2012 5:32 AM, Silvio Bierman wrote:
    > On 05/29/2012 02:16 PM, bilsch wrote:
    >> I'm writing a DOS script that uses pathnames with the well known Windows
    >> directory 'My Documents'. The name has a space in it that causes javac
    >> and java commands to choke. Neither of the following works:
    >> 'My Documents' (single quotes) or My\ Documents (escape the space).
    >> Here is an example:
    >>
    >> javac -d C:/Users/Owner/'My Documents'/NetBeansProjects/%1/build/classes
    >>
    >> Can anyone tell me the workaround for this?
    >>
    >> TIA Bill S.

    >
    > Not really Java related but anyway: in DOS/Windows you need to quote the
    > complete path like "C:/My Documents/Pictures/abc.WMV" etc.
    >
    > Silvio
    >

    Thanks Silvio. I discovered that the directory is called simply
    'Documents' in DOS instead of 'My Documents' as in Windows. So there's
    no need of quoting. The javac command produces a class file.

    Thanks Bill S.
    bilsch, May 29, 2012
    #7
  8. bilsch

    bilsch Guest

    On 5/29/2012 5:58 AM, Nigel Wade wrote:
    > On 29/05/12 13:32, Silvio Bierman wrote:
    >> On 05/29/2012 02:16 PM, bilsch wrote:
    >>> I'm writing a DOS script that uses pathnames with the well known Windows
    >>> directory 'My Documents'. The name has a space in it that causes javac
    >>> and java commands to choke. Neither of the following works:
    >>> 'My Documents' (single quotes) or My\ Documents (escape the space).
    >>> Here is an example:
    >>>
    >>> javac -d C:/Users/Owner/'My Documents'/NetBeansProjects/%1/build/classes
    >>>
    >>> Can anyone tell me the workaround for this?
    >>>
    >>> TIA Bill S.

    >>
    >> Not really Java related but anyway: in DOS/Windows you need to quote the
    >> complete path like "C:/My Documents/Pictures/abc.WMV" etc.
    >>

    >
    > it's often very convenient to use tab expansion of paths (both in
    > Windows cmd shell, and UNIX/Linux bash shell). This would have
    > discovered the correct path for the OP. For example, enter in the cmd.exe:
    >
    > javac -d C:\Users\Owner\My
    >
    > then hit tab. Windows will do the rest, even adding appropriate quotes
    > where necessary. Note that you must use the Windows \ path separator for
    > this to work.
    >

    Thanks for the info.
    bilsch, May 29, 2012
    #8
  9. bilsch

    bilsch Guest

    On 5/29/2012 7:06 AM, Lew wrote:
    > Nigel Wade wrote:
    >> Silvio Bierman wrote:
    >>> bilsch wrote:
    >>>> I'm writing a DOS script that uses pathnames with the well known
    >>>> Windows
    >>>> directory 'My Documents'. The name has a space in it that causes javac
    >>>> and java commands to choke. Neither of the following works:
    >>>> 'My Documents' (single quotes) or My\ Documents (escape the space).
    >>>> Here is an example:
    >>>>
    >>>> javac -d C:/Users/Owner/'My
    >>>> Documents'/NetBeansProjects/%1/build/classes
    >>>>
    >>>> Can anyone tell me the workaround for this?
    >>>>
    >>>> TIA Bill S.
    >>>
    >>> Not really Java related but anyway: in DOS/Windows you need to quote the
    >>> complete path like "C:/My Documents/Pictures/abc.WMV" etc.
    >>>

    >>
    >> it's often very convenient to use tab expansion of paths (both in
    >> Windows cmd
    >> shell, and UNIX/Linux bash shell). This would have discovered the
    >> correct path
    >> for the OP. For example, enter in the cmd.exe:
    >>
    >> javac -d C:\Users\Owner\My
    >>
    >> then hit tab. Windows will do the rest, even adding appropriate quotes
    >> where
    >> necessary. Note that you must use the Windows \ path separator for
    >> this to work.

    >
    > "/" is a Windows path *element* separator. ";" is the path separator in
    > Windows.
    >
    > Windows is fine with forward slashes in paths. I suspect the "%1"
    > expansion.
    >

    I discovered that the directory is called simply 'Documents' in DOS
    instead of 'My Documents' as in Windows. So there's no need of quoting.
    The javac command produces a class file.
    bilsch, May 29, 2012
    #9
  10. bilsch

    bilsch Guest

    On 5/29/2012 7:31 AM, Mike Schilling wrote:
    > "bilsch"<> wrote in message
    > news:jq2eme$o07$...
    >> I'm writing a DOS script that uses pathnames with the well known Windows
    >> directory 'My Documents'. The name has a space in it that causes javac and
    >> java commands to choke. Neither of the following works:
    >> 'My Documents' (single quotes) or My\ Documents (escape the space).
    >> Here is an example:
    >>
    >> javac -d C:/Users/Owner/'My Documents'/NetBeansProjects/%1/build/classes
    >>
    >> Can anyone tell me the workaround for this?

    > Two things to try:
    >
    > 1. Use double-quotes instead of single ones.
    > 2. Use "dir /x" to discover the short name for "My Documents" (I'd guess
    > it's MYDOCU~1) and use that instead.
    >
    >

    I discovered that the directory is called simply 'Documents' in DOS
    instead of 'My Documents' as in Windows. So there's no need of quoting.
    I did try using the short DOS name for Documents, which is DOCUME~1,
    and that does work. The javac command produces a class file.
    bilsch, May 29, 2012
    #10
  11. bilsch

    Lew Guest

    Re: Space in 'My Documents' directory not fixed by quoting or \escaping

    Gene Wirchenko wrote:
    > Lew wrote:
    >> Gene Wirchenko wrote:
    >>> then hit tab. Windows will do the rest, even adding appropriate quotes where
    >>> necessary. Note that you must use the Windows \ path separator for this to work.

    >>
    >>"/" is a Windows path *element* separator. ";" is the path separator in Windows.
    >>
    >>Windows is fine with forward slashes in paths. I suspect the "%1" expansion.

    >
    > But since using "/" as a path element seprator in a command line
    > will cause trouble, people tend to avoid using them as such.


    That is interesting to me. What trouble?

    I have used forward slashes as path element separators in Windows
    command-line commands. I don't recall that it caused any trouble.

    I'm always learning from this forum.

    --
    Lew
    Lew, May 29, 2012
    #11
  12. Lew <> wrote:

    (snip)
    >> But since using "/" as a path element seprator in a command line
    >> will cause trouble, people tend to avoid using them as such.


    > That is interesting to me. What trouble?


    > I have used forward slashes as path element separators in Windows
    > command-line commands. I don't recall that it caused any trouble.


    The system calls, such as OPEN, accept either / or \.
    (C programmers use / for #include files, knowing it will work
    on unix or DOS/Windows, at least since DOS 3.2.)

    The system command line utilities, such as DIR and COPY use / for
    options, and won't accept it as part of a file path.

    Other command line utilities (that don't come with DOS/Windows)
    that don't use / for options likely will accept /.

    The Sourceforge UNXUTILS, unix-like utilities for WIN32,
    for example, should accept /.

    -- glen
    glen herrmannsfeldt, May 29, 2012
    #12
  13. bilsch

    Jim Janney Guest

    glen herrmannsfeldt <> writes:

    > Lew <> wrote:
    >
    > (snip)
    >>> But since using "/" as a path element seprator in a command line
    >>> will cause trouble, people tend to avoid using them as such.

    >
    >> That is interesting to me. What trouble?

    >
    >> I have used forward slashes as path element separators in Windows
    >> command-line commands. I don't recall that it caused any trouble.

    >
    > The system calls, such as OPEN, accept either / or \.
    > (C programmers use / for #include files, knowing it will work
    > on unix or DOS/Windows, at least since DOS 3.2.)
    >
    > The system command line utilities, such as DIR and COPY use / for
    > options, and won't accept it as part of a file path.
    >
    > Other command line utilities (that don't come with DOS/Windows)
    > that don't use / for options likely will accept /.
    >
    > The Sourceforge UNXUTILS, unix-like utilities for WIN32,
    > for example, should accept /.


    In early versions of MS-DOS you could put a line in CONFIG.SYS to set
    the switch character to something else, usually -, which then freed up /
    for use in file names. This eventually went away, I don't remember
    exactly when. The problem was never in the API but in user code that
    parsed command lines.

    --
    Jim Janney
    Jim Janney, May 29, 2012
    #13
  14. bilsch

    bilsch Guest

    On 5/29/2012 2:55 PM, Gene Wirchenko wrote:
    > On Tue, 29 May 2012 14:07:29 -0700 (PDT), Lew<>
    > wrote:
    >
    >> Gene Wirchenko wrote:
    >>> Lew wrote:
    >>>> Gene Wirchenko wrote:
    >>>>> then hit tab. Windows will do the rest, even adding appropriate quotes where
    >>>>> necessary. Note that you must use the Windows \ path separator for this to work.
    >>>>
    >>>> "/" is a Windows path *element* separator. ";" is the path separator in Windows.
    >>>>
    >>>> Windows is fine with forward slashes in paths. I suspect the "%1" expansion.
    >>>
    >>> But since using "/" as a path element seprator in a command line
    >>> will cause trouble, people tend to avoid using them as such.

    >>
    >> That is interesting to me. What trouble?
    >>
    >> I have used forward slashes as path element separators in Windows
    >> command-line commands. I don't recall that it caused any trouble.

    >
    > I checked with Windows XP just before posting. The CLI did not
    > like
    > dir /download
    > and no wonder since "/" is used in many command-line programs for
    > indicating parameters. Windows 7 behaves the same way. (I just
    > checked.)
    >
    > It is easier to just use backslashes and not have to worry if
    > slash is acceptable in the current context. I prefer just typing and
    > not having to think about typing.
    >
    >> I'm always learning from this forum.

    >
    > So do I.
    >
    > Sincerely,
    >
    > Gene Wirchenko


    Forward slash works
    bilsch, May 30, 2012
    #14
  15. bilsch

    Nigel Wade Guest

    On 29/05/12 15:06, Lew wrote:
    > Nigel Wade wrote:


    >>
    >> it's often very convenient to use tab expansion of paths (both in
    >> Windows cmd
    >> shell, and UNIX/Linux bash shell). This would have discovered the
    >> correct path
    >> for the OP. For example, enter in the cmd.exe:
    >>
    >> javac -d C:\Users\Owner\My
    >>
    >> then hit tab. Windows will do the rest, even adding appropriate quotes
    >> where
    >> necessary. Note that you must use the Windows \ path separator for
    >> this to work.

    >
    > "/" is a Windows path *element* separator. ";" is the path separator in
    > Windows.
    >
    > Windows is fine with forward slashes in paths.
    >


    But not in tab-expansion, as I said.


    --
    Nigel Wade
    Nigel Wade, May 30, 2012
    #15
  16. bilsch

    Lew Guest

    bilsch wrote:
    > Gene Wirchenko wrote:
    >> Lew wrote:
    >>
    >>> Gene Wirchenko wrote:
    >>>> Lew wrote:
    >>>>> Gene Wirchenko wrote:
    >>>>>> then hit tab. Windows will do the rest, even adding appropriate quotes
    >>>>>> where
    >>>>>> necessary. Note that you must use the Windows \ path separator for this
    >>>>>> to work.
    >>>>>
    >>>>> "/" is a Windows path *element* separator. ";" is the path separator in
    >>>>> Windows.
    >>>>>
    >>>>> Windows is fine with forward slashes in paths. I suspect the "%1" expansion.
    >>>>
    >>>> But since using "/" as a path element seprator in a command line
    >>>> will cause trouble, people tend to avoid using them as such.
    >>>
    >>> That is interesting to me. What trouble?
    >>>
    >>> I have used forward slashes as path element separators in Windows
    >>> command-line commands. I don't recall that it caused any trouble.

    >>
    >> I checked with Windows XP just before posting. The CLI did not
    >> like
    >> dir /download
    >> and no wonder since "/" is used in many command-line programs for
    >> indicating parameters. Windows 7 behaves the same way. (I just
    >> checked.)
    >>
    >> It is easier to just use backslashes and not have to worry if
    >> slash is acceptable in the current context. I prefer just typing and
    >> not having to think about typing.
    >>
    >>> I'm always learning from this forum.

    >>
    >> So do I.
    >>
    >> Sincerely,
    >>
    >> Gene Wirchenko

    >
    > Forward slash works


    That settles it, then.

    --
    Lew
    Honi soit qui mal y pense.
    http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg
    Lew, Jun 2, 2012
    #16
  17. On Sat, 02 Jun 2012 09:31:57 -0700, Lew <> wrote:

    >bilsch wrote:
    >> Gene Wirchenko wrote:
    >>> Lew wrote:


    [snip]

    >>>> I have used forward slashes as path element separators in Windows
    >>>> command-line commands. I don't recall that it caused any trouble.
    >>>
    >>> I checked with Windows XP just before posting. The CLI did not
    >>> like
    >>> dir /download
    >>> and no wonder since "/" is used in many command-line programs for
    >>> indicating parameters. Windows 7 behaves the same way. (I just
    >>> checked.)
    >>>
    >>> It is easier to just use backslashes and not have to worry if
    >>> slash is acceptable in the current context. I prefer just typing and
    >>> not having to think about typing.
    >>>
    >>>> I'm always learning from this forum.
    >>>
    >>> So do I.


    >> Forward slash works

    >
    >That settles it, then.


    Hardly. I mentioned where I checked it, and it most definitely
    did not work.

    Sincerely,

    Gene Wirchenko
    Gene Wirchenko, Jun 4, 2012
    #17
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shuo Xiang

    Stack space, global space, heap space

    Shuo Xiang, Jul 9, 2003, in forum: C Programming
    Replies:
    10
    Views:
    2,890
    Bryan Bullard
    Jul 11, 2003
  2. Christian Seberino
    Replies:
    21
    Views:
    1,653
    Stephen Horne
    Oct 27, 2003
  3. Ian Bicking
    Replies:
    2
    Views:
    1,009
    Steve Lamb
    Oct 23, 2003
  4. Ian Bicking
    Replies:
    2
    Views:
    722
    Michael Hudson
    Oct 24, 2003
  5. Jim Ford
    Replies:
    3
    Views:
    419
    Raymundo
    May 19, 2007
Loading...

Share This Page