svnbatch-filesvnlook

batch FOR /F and space in file/pathname and usage of token?


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!


Solution

  • 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