1

My problem is pretty simple, but I'm unsure why I am seeing this behaviour. I want to get a list of parameters down to a single entry at a time so I can do some processing on them. The list of jar files I am processing is separated by a ; delimiter.

set JARS=this.jar;that.jar;and.jar;the.jar;other.jar
for /f "delims=;" %%a in ("%JARS%") do echo.%%a

I'm expecting the script to exit listing as follows.

this.jar
that.jar
and.jar
the.jar
other.jar
C:\>

But the script is instead exiting as follows.

this.jar
C:\>

I'm clearly missing something obvious, but I can't seem to see it.

I'm using Windows 7.

5
  • 1
    FOR /F will parse the content line by line first, then use the delimiter to separate the line into tokens. In your case, the content of JARS is on a single line, so you only get the first token. Commented Feb 6, 2014 at 15:59
  • Thanks for the help. Foxidrive's answer is saying the same as you mention, but the answer is still not right. Any thoughts on how I can tokenize a single line? Commented Feb 6, 2014 at 16:16
  • I am getting the expected output with @foxidrive's answer. What kind of output are you getting? Commented Feb 6, 2014 at 16:22
  • Strange. I just tried again and it worked. I must have had something else playing up and confused myself with the answer. Thanks! Commented Feb 6, 2014 at 16:26
  • You should also upvote foxidrive's answer if it helped you. ;) Commented Feb 6, 2014 at 16:27

1 Answer 1

3

Try this: The semicolon is a separator on a command line so it will delimit the filenames.

set JARS=this.jar;that.jar;and.jar;the.jar;other.jar
for %%a in (%JARS%) do echo.%%a
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.