Domanda

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!

È stato utile?

Soluzione

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

Altri suggerimenti

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
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top