Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The script I am using is
FOR /F "tokens=91 delims=<>" %%v IN ('curl') DO ECHO %%v
What I want it to do is search the output of
(copy and paste the url to see it. in command prompt, the command puts it's all on one line though)
for <artifact><displayPath> **THIS BIT HERE** </displayPath> and echo the result. When I run it, however, it displays the cURL downloading info, but doesn't echo anything at all. What do I need to change in my script?

share|improve this question
up vote 1 down vote accepted

The issue is "tokens=91", the maximum allowed token number is 31. You need a special technique to deal with such xml files with over 3000 chars per line in batch. This technique is beyond the scope of an answer at SU.

BTW: if you want to check out the max number of tokens you can use the following code:

@echo off &setlocal enabledelayedexpansion
set /a maxtok=40
set /a curtok=0

for /l %%i in (1,1,%maxtok%) do set "tokvar=!tokvar! %%i"
echo variable with tokens: %tokvar%
set /a curtok+=1
set "disptok="
for /f "tokens=%curtok%" %%i in ("%tokvar%") do set "disptok=%%i"
echo %disptok% ^<-- there should be number %curtok%
if %curtok% lss %maxtok% goto :tokloop

Insted, you can try the following code after download the xml and put it in a file (file.xml):

@echo off &setlocal
set "xmlfile=file.xml"
set "prefix=<artifact><displayPath>"

for /f "delims=" %%i in (%xmlfile%) do if not defined xmlline set "xmlline=%%i"
setlocal enabledelayedexpansion
set /a xmlcount+=1
set "xmlline=!xmlline:*%prefix%=!"
for /f "delims=<" %%i in ("%xmlline%") do set "line%xmlcount%=%%i"
if %xmlcount% lss 3 goto:xmlloop
echo %line1%
echo %line2%
echo %line3%
share|improve this answer
Thanks, I was wondering why it didn't work even though the command syntax was correct. I'll try making a script that'll delete the first 90 characters (in steps of 30) and post it here if I manage to get it working. – Craft1n3ss Apr 26 '13 at 22:45
After a long walk with my dog I got another idea, please check it out. – Endoro Apr 27 '13 at 2:00
Thanks! I've found another method as well. If you use curl -g "‌​ifacts[relativePath]", you'll just get the paths. Here's what I eventually got: FOR /F "tokens=14 delims=<>" %%a IN ('curl -g "‌​ifacts[relativePath]"') DO ECHO url = "" > Cache\Multiverse-Core.txt curl -z plugins\Multiverse-Core.jar -K Cache\Multiverse-Core.txt – Craft1n3ss Apr 27 '13 at 6:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.