Using a system variable with spaces without truncating prematurely

4

I need to do something similar to this:

dir > %USERNAME%.txt

But what I get is that if the filename has a SPACE(" ") in it, then the name is cut there.

I know that if I do this:

set tmp=%USERNAME%.txt

I have the desired filename.

How can I add the quotes (") using my original syntax? Is there another solution?

Diga

Posted 2011-11-14T09:48:42.950

Reputation: 43

Answers

7

I suggest you to try

dir > "%USERNAME%.txt"

Michael K

Posted 2011-11-14T09:48:42.950

Reputation: 3 308