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

B

bilsch

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.
 
S

Silvio Bierman

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
 
N

Nigel Wade

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.
 
L

Lew

Nigel said:
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.
 
M

Mike Schilling

bilsch said:
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.
 
G

Gene Wirchenko

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
 
B

bilsch

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.
 
B

bilsch

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.
 
B

bilsch

"/" 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.
 
B

bilsch

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.
 
L

Lew

Gene said:
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.
 
G

glen herrmannsfeldt

(snip)
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
 
J

Jim Janney

glen herrmannsfeldt said:
(snip)



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.
 
B

bilsch

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.


So do I.

Sincerely,

Gene Wirchenko

Forward slash works
 
N

Nigel Wade

Nigel Wade wrote:

"/" 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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top