2

I am using a batch file to update only those files that have changed in my SVN repository. This is a part of my batch file:

SET CHANGES=svnlook changed c:\myrepository
FOR /F "usebackq tokens=2" %%a IN (`%CHANGES%`) DO (echo %%a)

I only get dok instead of dok version1.txt and I guess thats because of the space. How must I change the code to get the filename even if there is a space? Is that because of the tokens or where does it cut the name?

The output of svnlook looks like:

D Testprojekt/trunk/dok - Kopie (2).txt
D Testprojekt/trunk/dok - Kopie (3).txt
D Testprojekt/trunk/dok - Kopie (4).txt

So I am using tokens=2 to only get the path (Testprojekt/trunk/dok - Kopie (2).txt) and not the action (D=deleted for example).

Thanks!

EOB
  • 2,975
  • 17
  • 43
  • 70

2 Answers2

3

Try using:

FOR /F "usebackq tokens=1,*" %%a IN (`%CHANGES%`) DO (echo %%b)

This assigns the first token to %a and all subsequent ones to the next letter i.e. %b

Grhm
  • 6,726
  • 4
  • 40
  • 64
2

With this output:

D Testprojekt/trunk/dok - Kopie (2).txt
D Testprojekt/trunk/dok - Kopie (3).txt
D Testprojekt/trunk/dok - Kopie (4).txt

... you can try this:

FOR /F "usebackq tokens=1*" %%a IN (`%CHANGES%`) DO (
    echo %%b
)

The tokens=1* bit means:

  1. Store first token into %%a (i.e. D)
  2. Store the rest of the line into %%b
Álvaro González
  • 142,137
  • 41
  • 261
  • 360