在Windows批处理脚本中从SVN获取一组修订

时间:2022-05-18 11:43:36

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:

我正在编写一个用于同步SVN存储库的脚本。这是我的第一个Windows批处理脚本,所以我遇到了一些问题。我使用“svn log -q”命令,它给出了存储在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 
------------------------------------------------------------------------

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.).

我想得的只是修订号。我使用下面的代码来获得修订,但它们与前导“r”(r1,r2等)。

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

谢谢你,szeldon

1 个解决方案

#1


0  

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

带有delims 和r的简单FOR / F应该可以工作,因为r后面总是有一个空格。

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

#1


0  

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

带有delims 和r的简单FOR / F应该可以工作,因为r后面总是有一个空格。

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