9 Comments

  1. Earl said:

    This is exacly what I was looking for. After digging into it a little more, I figure out you can shorten it to:

    (echo.|set /p =”%USERNAME%”)>session.nam

    November 22, 2009
    Reply
  2. said:

    Earl, thanks for the post, I’ll have to try your shortened version. I used to think that batch files were swell, until I just recently got into Linux shell scripting. Shell scripting is considerably more impressive.
    -Aaron

    November 23, 2009
    Reply
  3. said:

    You are brilliant brother…this saved me a butt-load of time! Thanks!

    March 22, 2010
    Reply
  4. Sriparna said:

    Thanks Earl, I was looking for exactly this solution. It has immensely helped me in creating my data files…best wishes

    March 23, 2010
    Reply
    • said:

      It’s Aaron. And you’re welcome.

      March 23, 2010
      Reply
  5. Klebom said:

    Can be simplified to:

    set /p x=”%USERNAME%” session.nam

    June 21, 2010
    Reply
    • said:

      Haven’t seen that one…where is this manual of batch files hidden?

      June 21, 2010
      Reply
  6. arun said:

    Cool man …you saved my day :-)

    July 6, 2010
    Reply
  7. Doc said:

    What if we were to want ot preserve leading spaces in our variable? I have a need to create a data file that is one line long which is right justified & padded at the left with no cr/lf at the end. Your solution is great in that it supresses the cr/lf at the end – But it also strips out the leading space(s) from my variable. The number of spaces I need is unknown. I always want the total length (spaces + data) to equal 10.

    February 14, 2011
    Reply

Leave a Reply to Sriparna Cancel reply

Your email address will not be published. Required fields are marked *