开发者

Getting a set of revisions from SVN in Windows batch script

开发者 https://www.devze.com 2023-03-11 09:38 出处:网络
I\'m writing a script for synchronisation of SVN repositories. It\'s my first Windows batch script, so I have some problems with it. I use \"svn log -q\" command which gives revision numbers like this

I'm writing a script for synchronisation of SVN repositories. It's my first Windows batch script, so I have some problems with it. I use "svn log -q" command which gives revision numbers like this that are stored in SVN_LOG_Q_FILE:

------------------------------------------------------------------------
r4 | username | 2011-05-26 13:31:04 +0100 
------------------------------------------------------------------------
r3 | username | 2011-05-26 13:27:33 +0100 
------------------------------------------------------------------------
r2 | username | 2011-05-26 15:39:29 +0100 
------------------------------------------------------------------------
r1 | username | 2011-05-26 13:37:41 +0100 
--------------------开发者_如何学Go----------------------------------------------------

What I'd like to get is only revision numbers. I use below code for getting revisions, but they're with leading "r" (r1, r2 etc.).

for /f "usebackq tokens=1" %%g in (`findstr /r /c:"r" %SVN_LOG_Q_FILE%`) do (
    echo rev %%g%
)

Can you help me?

Thanks in advance, szeldon


A simple FOR /F with the delims <space> and r should work, as there is always a space behind the r.

for /f "usebackq tokens=1 delims=r " %%g in ("%SVN_LOG_Q_FILE%") do (
    echo rev %%g
)
0

精彩评论

暂无评论...
验证码 换一张
取 消